spamassassin/spamassassin.patch

changeset 629
27f852b7efd2
parent 628
10fbfbc9b548
child 630
561e962f5a6e
     1.1 --- a/spamassassin/spamassassin.patch	Tue Aug 28 19:00:40 2012 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,250 +0,0 @@
     1.4 -Index: lib/Mail/SpamAssassin/Dns.pm
     1.5 ---- lib/Mail/SpamAssassin/Dns.pm.orig	2010-03-16 15:49:21.000000000 +0100
     1.6 -+++ lib/Mail/SpamAssassin/Dns.pm	2011-02-08 16:03:06.000000000 +0100
     1.7 -@@ -754,7 +754,7 @@
     1.8 -   dbg("dns: entering helper-app run mode");
     1.9 -   $self->{old_slash} = $/;              # Razor pollutes this
    1.10 -   %{$self->{old_env}} = ();
    1.11 --  if ( defined %ENV ) {
    1.12 -+  if (%ENV) {
    1.13 -     # undefined values in %ENV can result due to autovivification elsewhere,
    1.14 -     # this prevents later possible warnings when we restore %ENV
    1.15 -     while (my ($key, $value) = each %ENV) {
    1.16 -Index: lib/Mail/SpamAssassin/HTML.pm
    1.17 ---- lib/Mail/SpamAssassin/HTML.pm.orig	2010-03-16 15:49:21.000000000 +0100
    1.18 -+++ lib/Mail/SpamAssassin/HTML.pm	2011-02-08 16:03:06.000000000 +0100
    1.19 -@@ -191,7 +191,7 @@
    1.20 -   my $self = shift;
    1.21 -   my %options = @_;
    1.22 - 
    1.23 --  return join('', @{ $self->{text} }) unless keys %options;
    1.24 -+  return join('', @{ $self->{text} }) unless %options;
    1.25 - 
    1.26 -   my $mask;
    1.27 -   while (my ($k, $v) = each %options) {
    1.28 -Index: lib/Mail/SpamAssassin/Plugin/AntiVirus.pm
    1.29 ---- lib/Mail/SpamAssassin/Plugin/AntiVirus.pm.orig	2010-03-16 15:49:21.000000000 +0100
    1.30 -+++ lib/Mail/SpamAssassin/Plugin/AntiVirus.pm	2011-02-08 16:04:30.000000000 +0100
    1.31 -@@ -98,9 +98,9 @@
    1.32 -     my ($ctype, $boundary, $charset, $name) =
    1.33 -       Mail::SpamAssassin::Util::parse_content_type($p->get_header('content-type'));
    1.34 - 
    1.35 --    $name = lc $name || '';
    1.36 -+    $name = lc($name || '');
    1.37 - 
    1.38 --    my $cte = lc $p->get_header('content-transfer-encoding') || '';
    1.39 -+    my $cte = lc($p->get_header('content-transfer-encoding') || '');
    1.40 -     $ctype = lc $ctype;
    1.41 - 
    1.42 -     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)$/)
    1.43 -Index: lib/Mail/SpamAssassin/Plugin/BodyEval.pm
    1.44 ---- lib/Mail/SpamAssassin/Plugin/BodyEval.pm.orig	2010-03-16 15:49:21.000000000 +0100
    1.45 -+++ lib/Mail/SpamAssassin/Plugin/BodyEval.pm	2011-02-08 16:03:06.000000000 +0100
    1.46 -@@ -119,7 +119,7 @@
    1.47 -         }
    1.48 - 
    1.49 - 	# If there are no words, mark if there's at least 1 image ...
    1.50 --	if (keys %html == 0 && exists $pms->{html}{inside}{img}) {
    1.51 -+	if (!%html && exists $pms->{html}{inside}{img}) {
    1.52 - 	  # Use "\n" as the mark since it can't ever occur normally
    1.53 - 	  $html{"\n"}=1;
    1.54 - 	}
    1.55 -Index: lib/Mail/SpamAssassin/Plugin/Check.pm
    1.56 ---- lib/Mail/SpamAssassin/Plugin/Check.pm.orig	2010-03-16 15:49:21.000000000 +0100
    1.57 -+++ lib/Mail/SpamAssassin/Plugin/Check.pm	2011-02-08 16:03:06.000000000 +0100
    1.58 -@@ -307,64 +307,51 @@
    1.59 -   my $package_name = __PACKAGE__;
    1.60 -   my $methodname = $package_name."::_".$ruletype."_tests_".$clean_priority;
    1.61 - 
    1.62 --  if (defined &{$methodname} && !$doing_user_rules) {
    1.63 --run_compiled_method:
    1.64 --  # dbg("rules: run_generic_tests - calling %s", $methodname);
    1.65 --    my $t = Mail::SpamAssassin::Timeout->new({ deadline => $master_deadline });
    1.66 --    my $err = $t->run(sub {
    1.67 --      no strict "refs";
    1.68 --      $methodname->($pms, @{$opts{args}});
    1.69 --    });
    1.70 --    if ($t->timed_out() && $master_deadline && time > $master_deadline) {
    1.71 --      info("check: exceeded time limit in $methodname, skipping further tests");
    1.72 --      $pms->{deadline_exceeded} = 1;
    1.73 --    }
    1.74 --    return;
    1.75 --  }
    1.76 -+  if (!defined &{$methodname} || $doing_user_rules) {
    1.77 - 
    1.78 --  # use %nopts for named parameter-passing; it's more friendly to future-proof
    1.79 --  # subclassing, since new parameters can be added without breaking third-party
    1.80 --  # subclassed implementations of this plugin.
    1.81 --  my %nopts = (
    1.82 --    ruletype => $ruletype,
    1.83 --    doing_user_rules => $doing_user_rules,
    1.84 --    priority => $priority,
    1.85 --    clean_priority => $clean_priority
    1.86 --  );
    1.87 --
    1.88 --  # build up the eval string...
    1.89 --  $self->{evalstr_methodname} = $methodname;
    1.90 --  $self->{evalstr_chunk_current_methodname} = undef;
    1.91 --  $self->{evalstr_chunk_methodnames} = [];
    1.92 --  $self->{evalstr_chunk_prefix} = [];  # stack (array) of source code sections
    1.93 --  $self->{evalstr} = ''; $self->{evalstr_l} = 0;
    1.94 --  $self->{evalstr2} = '';
    1.95 --  $self->begin_evalstr_chunk($pms);
    1.96 --
    1.97 --  $self->push_evalstr_prefix($pms, '
    1.98 --      # start_rules_plugin_code '.$ruletype.' '.$priority.'
    1.99 --      my $scoresptr = $self->{conf}->{scores};
   1.100 --  ');
   1.101 --  if (defined $opts{pre_loop_body}) {
   1.102 --    $opts{pre_loop_body}->($self, $pms, $conf, %nopts);
   1.103 --  }
   1.104 --  $self->add_evalstr($pms,
   1.105 --                     $self->start_rules_plugin_code($ruletype, $priority) );
   1.106 --  while (my($rulename, $test) = each %{$opts{testhash}->{$priority}}) {
   1.107 --    $opts{loop_body}->($self, $pms, $conf, $rulename, $test, %nopts);
   1.108 --  }
   1.109 --  if (defined $opts{post_loop_body}) {
   1.110 --    $opts{post_loop_body}->($self, $pms, $conf, %nopts);
   1.111 --  }
   1.112 -+    # use %nopts for named parameter-passing; it's more friendly
   1.113 -+    # to future-proof subclassing, since new parameters can be added without
   1.114 -+    # breaking third-party subclassed implementations of this plugin.
   1.115 -+    my %nopts = (
   1.116 -+      ruletype => $ruletype,
   1.117 -+      doing_user_rules => $doing_user_rules,
   1.118 -+      priority => $priority,
   1.119 -+      clean_priority => $clean_priority
   1.120 -+    );
   1.121 -+
   1.122 -+    # build up the eval string...
   1.123 -+    $self->{evalstr_methodname} = $methodname;
   1.124 -+    $self->{evalstr_chunk_current_methodname} = undef;
   1.125 -+    $self->{evalstr_chunk_methodnames} = [];
   1.126 -+    $self->{evalstr_chunk_prefix} = []; # stack (array) of source code sections
   1.127 -+    $self->{evalstr} = ''; $self->{evalstr_l} = 0;
   1.128 -+    $self->{evalstr2} = '';
   1.129 -+    $self->begin_evalstr_chunk($pms);
   1.130 -+
   1.131 -+    $self->push_evalstr_prefix($pms, '
   1.132 -+        # start_rules_plugin_code '.$ruletype.' '.$priority.'
   1.133 -+        my $scoresptr = $self->{conf}->{scores};
   1.134 -+    ');
   1.135 -+    if (defined $opts{pre_loop_body}) {
   1.136 -+      $opts{pre_loop_body}->($self, $pms, $conf, %nopts);
   1.137 -+    }
   1.138 -+    $self->add_evalstr($pms,
   1.139 -+                       $self->start_rules_plugin_code($ruletype, $priority) );
   1.140 -+    while (my($rulename, $test) = each %{$opts{testhash}->{$priority}}) {
   1.141 -+      $opts{loop_body}->($self, $pms, $conf, $rulename, $test, %nopts);
   1.142 -+    }
   1.143 -+    if (defined $opts{post_loop_body}) {
   1.144 -+      $opts{post_loop_body}->($self, $pms, $conf, %nopts);
   1.145 -+    }
   1.146 - 
   1.147 --  $self->flush_evalstr($pms, 'run_generic_tests');
   1.148 --  $self->free_ruleset_source($pms, $ruletype, $priority);
   1.149 -+    $self->flush_evalstr($pms, 'run_generic_tests');
   1.150 -+    $self->free_ruleset_source($pms, $ruletype, $priority);
   1.151 - 
   1.152 --  # clear out a previous version of this method
   1.153 --  undef &{$methodname};
   1.154 -+    # clear out a previous version of this method
   1.155 -+    undef &{$methodname};
   1.156 - 
   1.157 --  # generate the loop that goes through each line...
   1.158 --  my $evalstr = <<"EOT";
   1.159 -+    # generate the loop that goes through each line...
   1.160 -+    my $evalstr = <<"EOT";
   1.161 -   {
   1.162 -     package $package_name;
   1.163 - 
   1.164 -@@ -373,40 +360,51 @@
   1.165 -     sub $methodname {
   1.166 - EOT
   1.167 - 
   1.168 --  for my $chunk_methodname (@{$self->{evalstr_chunk_methodnames}}) {
   1.169 --    $evalstr .= "      $chunk_methodname(\@_);\n";
   1.170 --  }
   1.171 -+    for my $chunk_methodname (@{$self->{evalstr_chunk_methodnames}}) {
   1.172 -+      $evalstr .= "      $chunk_methodname(\@_);\n";
   1.173 -+    }
   1.174 - 
   1.175 --  $evalstr .= <<"EOT";
   1.176 -+    $evalstr .= <<"EOT";
   1.177 -     }
   1.178 - 
   1.179 -     1;
   1.180 -   }
   1.181 - EOT
   1.182 - 
   1.183 --  delete $self->{evalstr};   # free up some RAM before we eval()
   1.184 --  delete $self->{evalstr2};
   1.185 --  delete $self->{evalstr_methodname};
   1.186 --  delete $self->{evalstr_chunk_current_methodname};
   1.187 --  delete $self->{evalstr_chunk_methodnames};
   1.188 --  delete $self->{evalstr_chunk_prefix};
   1.189 --
   1.190 --  dbg("rules: run_generic_tests - compiling eval code: %s, priority %s",
   1.191 --      $ruletype, $priority);
   1.192 --# dbg("rules: eval code to compile: $evalstr");
   1.193 --  my $eval_result;
   1.194 --  { my $timer = $self->{main}->time_method('compile_gen');
   1.195 --    $eval_result = eval($evalstr);
   1.196 --  }
   1.197 --  if (!$eval_result) {
   1.198 --    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
   1.199 --    warn "rules: failed to compile $ruletype tests, skipping:\n".
   1.200 --         "\t($eval_stat)\n";
   1.201 --    $pms->{rule_errors}++;
   1.202 --  }
   1.203 --  else {
   1.204 -+    delete $self->{evalstr};   # free up some RAM before we eval()
   1.205 -+    delete $self->{evalstr2};
   1.206 -+    delete $self->{evalstr_methodname};
   1.207 -+    delete $self->{evalstr_chunk_current_methodname};
   1.208 -+    delete $self->{evalstr_chunk_methodnames};
   1.209 -+    delete $self->{evalstr_chunk_prefix};
   1.210 -+
   1.211 -+    dbg("rules: run_generic_tests - compiling eval code: %s, priority %s",
   1.212 -+        $ruletype, $priority);
   1.213 -+  # dbg("rules: eval code to compile: $evalstr");
   1.214 -+    my $eval_result;
   1.215 -+    { my $timer = $self->{main}->time_method('compile_gen');
   1.216 -+      $eval_result = eval($evalstr);
   1.217 -+    }
   1.218 -+    if (!$eval_result) {
   1.219 -+      my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
   1.220 -+      warn "rules: failed to compile $ruletype tests, skipping:\n".
   1.221 -+           "\t($eval_stat)\n";
   1.222 -+      $pms->{rule_errors}++;
   1.223 -+      return;
   1.224 -+    }
   1.225 -     dbg("rules: compiled $ruletype tests");
   1.226 --    goto run_compiled_method;
   1.227 -+  }
   1.228 -+
   1.229 -+#run_compiled_method:
   1.230 -+# dbg("rules: run_generic_tests - calling %s", $methodname);
   1.231 -+  my $t = Mail::SpamAssassin::Timeout->new({ deadline => $master_deadline });
   1.232 -+  my $err = $t->run(sub {
   1.233 -+    no strict "refs";
   1.234 -+    $methodname->($pms, @{$opts{args}});
   1.235 -+  });
   1.236 -+  if ($t->timed_out() && $master_deadline && time > $master_deadline) {
   1.237 -+    info("check: exceeded time limit in $methodname, skipping further tests");
   1.238 -+    $pms->{deadline_exceeded} = 1;
   1.239 -   }
   1.240 - }
   1.241 - 
   1.242 -Index: lib/Mail/SpamAssassin/Plugin/MIMEEval.pm
   1.243 ---- lib/Mail/SpamAssassin/Plugin/MIMEEval.pm.orig	2010-03-16 15:49:21.000000000 +0100
   1.244 -+++ lib/Mail/SpamAssassin/Plugin/MIMEEval.pm	2011-02-08 16:03:32.000000000 +0100
   1.245 -@@ -498,7 +498,7 @@
   1.246 -     # perhaps just limit to test, and image?
   1.247 -     next if ($ctype eq 'application/ics');
   1.248 - 
   1.249 --    my $cte = lc $p->get_header('content-transfer-encoding') || '';
   1.250 -+    my $cte = lc($p->get_header('content-transfer-encoding') || '');
   1.251 -     next if ($cte !~ /^base64$/);
   1.252 -     foreach my $l ( @{$p->raw()} ) {
   1.253 -       my $len = length $l;

mercurial