|
1 Index: lib/Mail/SpamAssassin/Dns.pm |
|
2 --- lib/Mail/SpamAssassin/Dns.pm.orig 2010-03-16 15:49:21.000000000 +0100 |
|
3 +++ lib/Mail/SpamAssassin/Dns.pm 2011-02-08 16:03:06.000000000 +0100 |
|
4 @@ -754,7 +754,7 @@ |
|
5 dbg("dns: entering helper-app run mode"); |
|
6 $self->{old_slash} = $/; # Razor pollutes this |
|
7 %{$self->{old_env}} = (); |
|
8 - if ( defined %ENV ) { |
|
9 + if (%ENV) { |
|
10 # undefined values in %ENV can result due to autovivification elsewhere, |
|
11 # this prevents later possible warnings when we restore %ENV |
|
12 while (my ($key, $value) = each %ENV) { |
|
13 Index: lib/Mail/SpamAssassin/HTML.pm |
|
14 --- lib/Mail/SpamAssassin/HTML.pm.orig 2010-03-16 15:49:21.000000000 +0100 |
|
15 +++ lib/Mail/SpamAssassin/HTML.pm 2011-02-08 16:03:06.000000000 +0100 |
|
16 @@ -191,7 +191,7 @@ |
|
17 my $self = shift; |
|
18 my %options = @_; |
|
19 |
|
20 - return join('', @{ $self->{text} }) unless keys %options; |
|
21 + return join('', @{ $self->{text} }) unless %options; |
|
22 |
|
23 my $mask; |
|
24 while (my ($k, $v) = each %options) { |
|
25 Index: lib/Mail/SpamAssassin/Plugin/AntiVirus.pm |
|
26 --- lib/Mail/SpamAssassin/Plugin/AntiVirus.pm.orig 2010-03-16 15:49:21.000000000 +0100 |
|
27 +++ lib/Mail/SpamAssassin/Plugin/AntiVirus.pm 2011-02-08 16:04:30.000000000 +0100 |
|
28 @@ -98,9 +98,9 @@ |
|
29 my ($ctype, $boundary, $charset, $name) = |
|
30 Mail::SpamAssassin::Util::parse_content_type($p->get_header('content-type')); |
|
31 |
|
32 - $name = lc $name || ''; |
|
33 + $name = lc($name || ''); |
|
34 |
|
35 - my $cte = lc $p->get_header('content-transfer-encoding') || ''; |
|
36 + my $cte = lc($p->get_header('content-transfer-encoding') || ''); |
|
37 $ctype = lc $ctype; |
|
38 |
|
39 if ($name && $name =~ /\.(?:ade|adp|asx|bas|bat|chm|cmd|com|cpl|crt|dll|exe|hlp|hta|inf|ins|isp|js|jse|lnk|mda|mdb|mde|mdt|mdw|mdz|msc|msi|msp|mst|nws|ops|pcd|pif|prf|reg|scf|scr\??|sct|shb|shs|shm|swf|url|vb|vbe|vbs|vbx|vxd|wsc|wsf|wsh)$/) |
|
40 Index: lib/Mail/SpamAssassin/Plugin/BodyEval.pm |
|
41 --- lib/Mail/SpamAssassin/Plugin/BodyEval.pm.orig 2010-03-16 15:49:21.000000000 +0100 |
|
42 +++ lib/Mail/SpamAssassin/Plugin/BodyEval.pm 2011-02-08 16:03:06.000000000 +0100 |
|
43 @@ -119,7 +119,7 @@ |
|
44 } |
|
45 |
|
46 # If there are no words, mark if there's at least 1 image ... |
|
47 - if (keys %html == 0 && exists $pms->{html}{inside}{img}) { |
|
48 + if (!%html && exists $pms->{html}{inside}{img}) { |
|
49 # Use "\n" as the mark since it can't ever occur normally |
|
50 $html{"\n"}=1; |
|
51 } |
|
52 Index: lib/Mail/SpamAssassin/Plugin/Check.pm |
|
53 --- lib/Mail/SpamAssassin/Plugin/Check.pm.orig 2010-03-16 15:49:21.000000000 +0100 |
|
54 +++ lib/Mail/SpamAssassin/Plugin/Check.pm 2011-02-08 16:03:06.000000000 +0100 |
|
55 @@ -307,64 +307,51 @@ |
|
56 my $package_name = __PACKAGE__; |
|
57 my $methodname = $package_name."::_".$ruletype."_tests_".$clean_priority; |
|
58 |
|
59 - if (defined &{$methodname} && !$doing_user_rules) { |
|
60 -run_compiled_method: |
|
61 - # dbg("rules: run_generic_tests - calling %s", $methodname); |
|
62 - my $t = Mail::SpamAssassin::Timeout->new({ deadline => $master_deadline }); |
|
63 - my $err = $t->run(sub { |
|
64 - no strict "refs"; |
|
65 - $methodname->($pms, @{$opts{args}}); |
|
66 - }); |
|
67 - if ($t->timed_out() && $master_deadline && time > $master_deadline) { |
|
68 - info("check: exceeded time limit in $methodname, skipping further tests"); |
|
69 - $pms->{deadline_exceeded} = 1; |
|
70 - } |
|
71 - return; |
|
72 - } |
|
73 + if (!defined &{$methodname} || $doing_user_rules) { |
|
74 |
|
75 - # use %nopts for named parameter-passing; it's more friendly to future-proof |
|
76 - # subclassing, since new parameters can be added without breaking third-party |
|
77 - # subclassed implementations of this plugin. |
|
78 - my %nopts = ( |
|
79 - ruletype => $ruletype, |
|
80 - doing_user_rules => $doing_user_rules, |
|
81 - priority => $priority, |
|
82 - clean_priority => $clean_priority |
|
83 - ); |
|
84 - |
|
85 - # build up the eval string... |
|
86 - $self->{evalstr_methodname} = $methodname; |
|
87 - $self->{evalstr_chunk_current_methodname} = undef; |
|
88 - $self->{evalstr_chunk_methodnames} = []; |
|
89 - $self->{evalstr_chunk_prefix} = []; # stack (array) of source code sections |
|
90 - $self->{evalstr} = ''; $self->{evalstr_l} = 0; |
|
91 - $self->{evalstr2} = ''; |
|
92 - $self->begin_evalstr_chunk($pms); |
|
93 - |
|
94 - $self->push_evalstr_prefix($pms, ' |
|
95 - # start_rules_plugin_code '.$ruletype.' '.$priority.' |
|
96 - my $scoresptr = $self->{conf}->{scores}; |
|
97 - '); |
|
98 - if (defined $opts{pre_loop_body}) { |
|
99 - $opts{pre_loop_body}->($self, $pms, $conf, %nopts); |
|
100 - } |
|
101 - $self->add_evalstr($pms, |
|
102 - $self->start_rules_plugin_code($ruletype, $priority) ); |
|
103 - while (my($rulename, $test) = each %{$opts{testhash}->{$priority}}) { |
|
104 - $opts{loop_body}->($self, $pms, $conf, $rulename, $test, %nopts); |
|
105 - } |
|
106 - if (defined $opts{post_loop_body}) { |
|
107 - $opts{post_loop_body}->($self, $pms, $conf, %nopts); |
|
108 - } |
|
109 + # use %nopts for named parameter-passing; it's more friendly |
|
110 + # to future-proof subclassing, since new parameters can be added without |
|
111 + # breaking third-party subclassed implementations of this plugin. |
|
112 + my %nopts = ( |
|
113 + ruletype => $ruletype, |
|
114 + doing_user_rules => $doing_user_rules, |
|
115 + priority => $priority, |
|
116 + clean_priority => $clean_priority |
|
117 + ); |
|
118 + |
|
119 + # build up the eval string... |
|
120 + $self->{evalstr_methodname} = $methodname; |
|
121 + $self->{evalstr_chunk_current_methodname} = undef; |
|
122 + $self->{evalstr_chunk_methodnames} = []; |
|
123 + $self->{evalstr_chunk_prefix} = []; # stack (array) of source code sections |
|
124 + $self->{evalstr} = ''; $self->{evalstr_l} = 0; |
|
125 + $self->{evalstr2} = ''; |
|
126 + $self->begin_evalstr_chunk($pms); |
|
127 + |
|
128 + $self->push_evalstr_prefix($pms, ' |
|
129 + # start_rules_plugin_code '.$ruletype.' '.$priority.' |
|
130 + my $scoresptr = $self->{conf}->{scores}; |
|
131 + '); |
|
132 + if (defined $opts{pre_loop_body}) { |
|
133 + $opts{pre_loop_body}->($self, $pms, $conf, %nopts); |
|
134 + } |
|
135 + $self->add_evalstr($pms, |
|
136 + $self->start_rules_plugin_code($ruletype, $priority) ); |
|
137 + while (my($rulename, $test) = each %{$opts{testhash}->{$priority}}) { |
|
138 + $opts{loop_body}->($self, $pms, $conf, $rulename, $test, %nopts); |
|
139 + } |
|
140 + if (defined $opts{post_loop_body}) { |
|
141 + $opts{post_loop_body}->($self, $pms, $conf, %nopts); |
|
142 + } |
|
143 |
|
144 - $self->flush_evalstr($pms, 'run_generic_tests'); |
|
145 - $self->free_ruleset_source($pms, $ruletype, $priority); |
|
146 + $self->flush_evalstr($pms, 'run_generic_tests'); |
|
147 + $self->free_ruleset_source($pms, $ruletype, $priority); |
|
148 |
|
149 - # clear out a previous version of this method |
|
150 - undef &{$methodname}; |
|
151 + # clear out a previous version of this method |
|
152 + undef &{$methodname}; |
|
153 |
|
154 - # generate the loop that goes through each line... |
|
155 - my $evalstr = <<"EOT"; |
|
156 + # generate the loop that goes through each line... |
|
157 + my $evalstr = <<"EOT"; |
|
158 { |
|
159 package $package_name; |
|
160 |
|
161 @@ -373,40 +360,51 @@ |
|
162 sub $methodname { |
|
163 EOT |
|
164 |
|
165 - for my $chunk_methodname (@{$self->{evalstr_chunk_methodnames}}) { |
|
166 - $evalstr .= " $chunk_methodname(\@_);\n"; |
|
167 - } |
|
168 + for my $chunk_methodname (@{$self->{evalstr_chunk_methodnames}}) { |
|
169 + $evalstr .= " $chunk_methodname(\@_);\n"; |
|
170 + } |
|
171 |
|
172 - $evalstr .= <<"EOT"; |
|
173 + $evalstr .= <<"EOT"; |
|
174 } |
|
175 |
|
176 1; |
|
177 } |
|
178 EOT |
|
179 |
|
180 - delete $self->{evalstr}; # free up some RAM before we eval() |
|
181 - delete $self->{evalstr2}; |
|
182 - delete $self->{evalstr_methodname}; |
|
183 - delete $self->{evalstr_chunk_current_methodname}; |
|
184 - delete $self->{evalstr_chunk_methodnames}; |
|
185 - delete $self->{evalstr_chunk_prefix}; |
|
186 - |
|
187 - dbg("rules: run_generic_tests - compiling eval code: %s, priority %s", |
|
188 - $ruletype, $priority); |
|
189 -# dbg("rules: eval code to compile: $evalstr"); |
|
190 - my $eval_result; |
|
191 - { my $timer = $self->{main}->time_method('compile_gen'); |
|
192 - $eval_result = eval($evalstr); |
|
193 - } |
|
194 - if (!$eval_result) { |
|
195 - my $eval_stat = $@ ne '' ? $@ : "errno=$!"; chomp $eval_stat; |
|
196 - warn "rules: failed to compile $ruletype tests, skipping:\n". |
|
197 - "\t($eval_stat)\n"; |
|
198 - $pms->{rule_errors}++; |
|
199 - } |
|
200 - else { |
|
201 + delete $self->{evalstr}; # free up some RAM before we eval() |
|
202 + delete $self->{evalstr2}; |
|
203 + delete $self->{evalstr_methodname}; |
|
204 + delete $self->{evalstr_chunk_current_methodname}; |
|
205 + delete $self->{evalstr_chunk_methodnames}; |
|
206 + delete $self->{evalstr_chunk_prefix}; |
|
207 + |
|
208 + dbg("rules: run_generic_tests - compiling eval code: %s, priority %s", |
|
209 + $ruletype, $priority); |
|
210 + # dbg("rules: eval code to compile: $evalstr"); |
|
211 + my $eval_result; |
|
212 + { my $timer = $self->{main}->time_method('compile_gen'); |
|
213 + $eval_result = eval($evalstr); |
|
214 + } |
|
215 + if (!$eval_result) { |
|
216 + my $eval_stat = $@ ne '' ? $@ : "errno=$!"; chomp $eval_stat; |
|
217 + warn "rules: failed to compile $ruletype tests, skipping:\n". |
|
218 + "\t($eval_stat)\n"; |
|
219 + $pms->{rule_errors}++; |
|
220 + return; |
|
221 + } |
|
222 dbg("rules: compiled $ruletype tests"); |
|
223 - goto run_compiled_method; |
|
224 + } |
|
225 + |
|
226 +#run_compiled_method: |
|
227 +# dbg("rules: run_generic_tests - calling %s", $methodname); |
|
228 + my $t = Mail::SpamAssassin::Timeout->new({ deadline => $master_deadline }); |
|
229 + my $err = $t->run(sub { |
|
230 + no strict "refs"; |
|
231 + $methodname->($pms, @{$opts{args}}); |
|
232 + }); |
|
233 + if ($t->timed_out() && $master_deadline && time > $master_deadline) { |
|
234 + info("check: exceeded time limit in $methodname, skipping further tests"); |
|
235 + $pms->{deadline_exceeded} = 1; |
|
236 } |
|
237 } |
|
238 |
|
239 Index: lib/Mail/SpamAssassin/Plugin/MIMEEval.pm |
|
240 --- lib/Mail/SpamAssassin/Plugin/MIMEEval.pm.orig 2010-03-16 15:49:21.000000000 +0100 |
|
241 +++ lib/Mail/SpamAssassin/Plugin/MIMEEval.pm 2011-02-08 16:03:32.000000000 +0100 |
|
242 @@ -498,7 +498,7 @@ |
|
243 # perhaps just limit to test, and image? |
|
244 next if ($ctype eq 'application/ics'); |
|
245 |
|
246 - my $cte = lc $p->get_header('content-transfer-encoding') || ''; |
|
247 + my $cte = lc($p->get_header('content-transfer-encoding') || ''); |
|
248 next if ($cte !~ /^base64$/); |
|
249 foreach my $l ( @{$p->raw()} ) { |
|
250 my $len = length $l; |