You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by he...@apache.org on 2022/05/07 09:21:33 UTC

svn commit: r1900648 - in /spamassassin/trunk/lib/Mail/SpamAssassin: Conf.pm Plugin/Bayes.pm

Author: hege
Date: Sat May  7 09:21:33 2022
New Revision: 1900648

URL: http://svn.apache.org/viewvc?rev=1900648&view=rev
Log:
No point mapping bayes_ignore_header constantly from array to lc hash, just make it lc hash from the start. Also make it more standards conforming, no point having differently named hash from the command.

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Bayes.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm?rev=1900648&r1=1900647&r2=1900648&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm Sat May  7 09:21:33 2022
@@ -2243,7 +2243,7 @@ a spam-filtering ISP or mailing list, an
 new headers (as most of them do), these headers may provide
 inappropriate cues to the Bayesian classifier, allowing it
 to take a "short cut". To avoid this, list the headers using this
-setting.  Example:
+setting. Header matching is case-insensitive.  Example:
 
         bayes_ignore_header X-Upstream-Spamfilter
         bayes_ignore_header X-Upstream-SomethingElse
@@ -2252,14 +2252,15 @@ setting.  Example:
 
   push (@cmds, {
     setting => 'bayes_ignore_header',
-    default => [],
-    type => $CONF_TYPE_STRINGLIST,
+    type => $CONF_TYPE_HASH_KEY_VALUE,
     code => sub {
       my ($self, $key, $value, $line) = @_;
       if ($value eq '') {
         return $MISSING_REQUIRED_VALUE;
       }
-      push (@{$self->{bayes_ignore_headers}}, split(/\s+/, $value));
+      foreach (split(/\s+/, $value)) {
+        $self->{bayes_ignore_header}->{lc $_} = 1;
+      }
     }
   });
 
@@ -4920,7 +4921,7 @@ sub new {
   $self->{headers_spam} = [ ];
   $self->{headers_ham} = [ ];
 
-  $self->{bayes_ignore_headers} = [ ];
+  $self->{bayes_ignore_header} = { };
   $self->{bayes_ignore_from} = { };
   $self->{bayes_ignore_to} = { };
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Bayes.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Bayes.pm?rev=1900648&r1=1900647&r2=1900648&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Bayes.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Bayes.pm Sat May  7 09:21:33 2022
@@ -1393,9 +1393,6 @@ sub _tokenize_headers {
 
   my %parsed;
 
-  my %user_ignore;
-  $user_ignore{lc $_} = 1 for @{$self->{main}->{conf}->{bayes_ignore_headers}};
-
   # get headers in array context
   my @hdrs;
   my @rcvdlines;
@@ -1423,7 +1420,7 @@ sub _tokenize_headers {
 
     # remove user-specified headers here, after Received, in case they
     # want to ignore that too
-    next if exists $user_ignore{lc $hdr};
+    next if exists $self->{conf}->{bayes_ignore_header}->{lc $hdr};
 
     # Prep the header value
     $val ||= '';