Added
Link Here
|
1 |
Index: lib/Mail/SpamAssassin/HTML.pm |
2 |
=================================================================== |
3 |
--- lib/Mail/SpamAssassin/HTML.pm (revision 943932) |
4 |
+++ lib/Mail/SpamAssassin/HTML.pm (revision 943933) |
5 |
@@ -191,7 +191,7 @@ |
6 |
my $self = shift; |
7 |
my %options = @_; |
8 |
|
9 |
- return join('', @{ $self->{text} }) unless keys %options; |
10 |
+ return join('', @{ $self->{text} }) unless %options; |
11 |
|
12 |
my $mask; |
13 |
while (my ($k, $v) = each %options) { |
14 |
Index: lib/Mail/SpamAssassin/Dns.pm |
15 |
=================================================================== |
16 |
--- lib/Mail/SpamAssassin/Dns.pm (revision 943932) |
17 |
+++ lib/Mail/SpamAssassin/Dns.pm (revision 943933) |
18 |
@@ -754,7 +754,7 @@ |
19 |
dbg("dns: entering helper-app run mode"); |
20 |
$self->{old_slash} = $/; # Razor pollutes this |
21 |
%{$self->{old_env}} = (); |
22 |
- if ( defined %ENV ) { |
23 |
+ if ( %ENV ) { |
24 |
# undefined values in %ENV can result due to autovivification elsewhere, |
25 |
# this prevents later possible warnings when we restore %ENV |
26 |
while (my ($key, $value) = each %ENV) { |
27 |
Index: lib/Mail/SpamAssassin/Plugin/Check.pm |
28 |
=================================================================== |
29 |
--- lib/Mail/SpamAssassin/Plugin/Check.pm (revision 943932) |
30 |
+++ lib/Mail/SpamAssassin/Plugin/Check.pm (revision 943933) |
31 |
@@ -307,64 +307,51 @@ |
32 |
my $package_name = __PACKAGE__; |
33 |
my $methodname = $package_name."::_".$ruletype."_tests_".$clean_priority; |
34 |
|
35 |
- if (defined &{$methodname} && !$doing_user_rules) { |
36 |
-run_compiled_method: |
37 |
- # dbg("rules: run_generic_tests - calling %s", $methodname); |
38 |
- my $t = Mail::SpamAssassin::Timeout->new({ deadline => $master_deadline }); |
39 |
- my $err = $t->run(sub { |
40 |
- no strict "refs"; |
41 |
- $methodname->($pms, @{$opts{args}}); |
42 |
- }); |
43 |
- if ($t->timed_out() && $master_deadline && time > $master_deadline) { |
44 |
- info("check: exceeded time limit in $methodname, skipping further tests"); |
45 |
- $pms->{deadline_exceeded} = 1; |
46 |
- } |
47 |
- return; |
48 |
- } |
49 |
+ if (!defined &{$methodname} || $doing_user_rules) { |
50 |
|
51 |
- # use %nopts for named parameter-passing; it's more friendly to future-proof |
52 |
- # subclassing, since new parameters can be added without breaking third-party |
53 |
- # subclassed implementations of this plugin. |
54 |
- my %nopts = ( |
55 |
- ruletype => $ruletype, |
56 |
- doing_user_rules => $doing_user_rules, |
57 |
- priority => $priority, |
58 |
- clean_priority => $clean_priority |
59 |
- ); |
60 |
+ # use %nopts for named parameter-passing; it's more friendly |
61 |
+ # to future-proof subclassing, since new parameters can be added without |
62 |
+ # breaking third-party subclassed implementations of this plugin. |
63 |
+ my %nopts = ( |
64 |
+ ruletype => $ruletype, |
65 |
+ doing_user_rules => $doing_user_rules, |
66 |
+ priority => $priority, |
67 |
+ clean_priority => $clean_priority |
68 |
+ ); |
69 |
|
70 |
- # build up the eval string... |
71 |
- $self->{evalstr_methodname} = $methodname; |
72 |
- $self->{evalstr_chunk_current_methodname} = undef; |
73 |
- $self->{evalstr_chunk_methodnames} = []; |
74 |
- $self->{evalstr_chunk_prefix} = []; # stack (array) of source code sections |
75 |
- $self->{evalstr} = ''; $self->{evalstr_l} = 0; |
76 |
- $self->{evalstr2} = ''; |
77 |
- $self->begin_evalstr_chunk($pms); |
78 |
+ # build up the eval string... |
79 |
+ $self->{evalstr_methodname} = $methodname; |
80 |
+ $self->{evalstr_chunk_current_methodname} = undef; |
81 |
+ $self->{evalstr_chunk_methodnames} = []; |
82 |
+ $self->{evalstr_chunk_prefix} = []; # stack (array) of source code sections |
83 |
+ $self->{evalstr} = ''; $self->{evalstr_l} = 0; |
84 |
+ $self->{evalstr2} = ''; |
85 |
+ $self->begin_evalstr_chunk($pms); |
86 |
|
87 |
- $self->push_evalstr_prefix($pms, ' |
88 |
- # start_rules_plugin_code '.$ruletype.' '.$priority.' |
89 |
- my $scoresptr = $self->{conf}->{scores}; |
90 |
- '); |
91 |
- if (defined $opts{pre_loop_body}) { |
92 |
- $opts{pre_loop_body}->($self, $pms, $conf, %nopts); |
93 |
- } |
94 |
- $self->add_evalstr($pms, |
95 |
- $self->start_rules_plugin_code($ruletype, $priority) ); |
96 |
- while (my($rulename, $test) = each %{$opts{testhash}->{$priority}}) { |
97 |
- $opts{loop_body}->($self, $pms, $conf, $rulename, $test, %nopts); |
98 |
- } |
99 |
- if (defined $opts{post_loop_body}) { |
100 |
- $opts{post_loop_body}->($self, $pms, $conf, %nopts); |
101 |
- } |
102 |
+ $self->push_evalstr_prefix($pms, ' |
103 |
+ # start_rules_plugin_code '.$ruletype.' '.$priority.' |
104 |
+ my $scoresptr = $self->{conf}->{scores}; |
105 |
+ '); |
106 |
+ if (defined $opts{pre_loop_body}) { |
107 |
+ $opts{pre_loop_body}->($self, $pms, $conf, %nopts); |
108 |
+ } |
109 |
+ $self->add_evalstr($pms, |
110 |
+ $self->start_rules_plugin_code($ruletype, $priority) ); |
111 |
+ while (my($rulename, $test) = each %{$opts{testhash}->{$priority}}) { |
112 |
+ $opts{loop_body}->($self, $pms, $conf, $rulename, $test, %nopts); |
113 |
+ } |
114 |
+ if (defined $opts{post_loop_body}) { |
115 |
+ $opts{post_loop_body}->($self, $pms, $conf, %nopts); |
116 |
+ } |
117 |
|
118 |
- $self->flush_evalstr($pms, 'run_generic_tests'); |
119 |
- $self->free_ruleset_source($pms, $ruletype, $priority); |
120 |
+ $self->flush_evalstr($pms, 'run_generic_tests'); |
121 |
+ $self->free_ruleset_source($pms, $ruletype, $priority); |
122 |
|
123 |
- # clear out a previous version of this method |
124 |
- undef &{$methodname}; |
125 |
+ # clear out a previous version of this method |
126 |
+ undef &{$methodname}; |
127 |
|
128 |
- # generate the loop that goes through each line... |
129 |
- my $evalstr = <<"EOT"; |
130 |
+ # generate the loop that goes through each line... |
131 |
+ my $evalstr = <<"EOT"; |
132 |
{ |
133 |
package $package_name; |
134 |
|
135 |
@@ -373,41 +360,52 @@ |
136 |
sub $methodname { |
137 |
EOT |
138 |
|
139 |
- for my $chunk_methodname (@{$self->{evalstr_chunk_methodnames}}) { |
140 |
- $evalstr .= " $chunk_methodname(\@_);\n"; |
141 |
- } |
142 |
+ for my $chunk_methodname (@{$self->{evalstr_chunk_methodnames}}) { |
143 |
+ $evalstr .= " $chunk_methodname(\@_);\n"; |
144 |
+ } |
145 |
|
146 |
- $evalstr .= <<"EOT"; |
147 |
+ $evalstr .= <<"EOT"; |
148 |
} |
149 |
|
150 |
1; |
151 |
} |
152 |
EOT |
153 |
|
154 |
- delete $self->{evalstr}; # free up some RAM before we eval() |
155 |
- delete $self->{evalstr2}; |
156 |
- delete $self->{evalstr_methodname}; |
157 |
- delete $self->{evalstr_chunk_current_methodname}; |
158 |
- delete $self->{evalstr_chunk_methodnames}; |
159 |
- delete $self->{evalstr_chunk_prefix}; |
160 |
+ delete $self->{evalstr}; # free up some RAM before we eval() |
161 |
+ delete $self->{evalstr2}; |
162 |
+ delete $self->{evalstr_methodname}; |
163 |
+ delete $self->{evalstr_chunk_current_methodname}; |
164 |
+ delete $self->{evalstr_chunk_methodnames}; |
165 |
+ delete $self->{evalstr_chunk_prefix}; |
166 |
|
167 |
- dbg("rules: run_generic_tests - compiling eval code: %s, priority %s", |
168 |
- $ruletype, $priority); |
169 |
-# dbg("rules: eval code to compile: $evalstr"); |
170 |
- my $eval_result; |
171 |
- { my $timer = $self->{main}->time_method('compile_gen'); |
172 |
- $eval_result = eval($evalstr); |
173 |
- } |
174 |
- if (!$eval_result) { |
175 |
- my $eval_stat = $@ ne '' ? $@ : "errno=$!"; chomp $eval_stat; |
176 |
- warn "rules: failed to compile $ruletype tests, skipping:\n". |
177 |
- "\t($eval_stat)\n"; |
178 |
- $pms->{rule_errors}++; |
179 |
- } |
180 |
- else { |
181 |
+ dbg("rules: run_generic_tests - compiling eval code: %s, priority %s", |
182 |
+ $ruletype, $priority); |
183 |
+ # dbg("rules: eval code to compile: $evalstr"); |
184 |
+ my $eval_result; |
185 |
+ { my $timer = $self->{main}->time_method('compile_gen'); |
186 |
+ $eval_result = eval($evalstr); |
187 |
+ } |
188 |
+ if (!$eval_result) { |
189 |
+ my $eval_stat = $@ ne '' ? $@ : "errno=$!"; chomp $eval_stat; |
190 |
+ warn "rules: failed to compile $ruletype tests, skipping:\n". |
191 |
+ "\t($eval_stat)\n"; |
192 |
+ $pms->{rule_errors}++; |
193 |
+ return; |
194 |
+ } |
195 |
dbg("rules: compiled $ruletype tests"); |
196 |
- goto run_compiled_method; |
197 |
} |
198 |
+ |
199 |
+#run_compiled_method: |
200 |
+# dbg("rules: run_generic_tests - calling %s", $methodname); |
201 |
+ my $t = Mail::SpamAssassin::Timeout->new({ deadline => $master_deadline }); |
202 |
+ my $err = $t->run(sub { |
203 |
+ no strict "refs"; |
204 |
+ $methodname->($pms, @{$opts{args}}); |
205 |
+ }); |
206 |
+ if ($t->timed_out() && $master_deadline && time > $master_deadline) { |
207 |
+ info("check: exceeded time limit in $methodname, skipping further tests"); |
208 |
+ $pms->{deadline_exceeded} = 1; |
209 |
+ } |
210 |
} |
211 |
|
212 |
sub begin_evalstr_chunk { |
213 |
Index: lib/Mail/SpamAssassin/Plugin/BodyEval.pm |
214 |
=================================================================== |
215 |
--- lib/Mail/SpamAssassin/Plugin/BodyEval.pm (revision 943932) |
216 |
+++ lib/Mail/SpamAssassin/Plugin/BodyEval.pm (revision 943933) |
217 |
@@ -119,7 +119,7 @@ |
218 |
} |
219 |
|
220 |
# If there are no words, mark if there's at least 1 image ... |
221 |
- if (keys %html == 0 && exists $pms->{html}{inside}{img}) { |
222 |
+ if (!%html && exists $pms->{html}{inside}{img}) { |
223 |
# Use "\n" as the mark since it can't ever occur normally |
224 |
$html{"\n"}=1; |
225 |
} |