spamassassin/spamassassin.patch

Fri, 10 Aug 2012 14:29:49 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 10 Aug 2012 14:29:49 +0200
changeset 510
f30946597115
permissions
-rw-r--r--

Correct defective definitions and add make dependency for parallel build.

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

mercurial