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/04/03 08:19:42 UTC

svn commit: r1899526 - in /spamassassin/trunk: UPGRADE lib/Mail/SpamAssassin/PerMsgStatus.pm lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm

Author: hege
Date: Sun Apr  3 08:19:41 2022
New Revision: 1899526

URL: http://svn.apache.org/viewvc?rev=1899526&view=rev
Log:
Add tflags autolearn_header/autolearn_body (Bug 7907)

Modified:
    spamassassin/trunk/UPGRADE
    spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm

Modified: spamassassin/trunk/UPGRADE
URL: http://svn.apache.org/viewvc/spamassassin/trunk/UPGRADE?rev=1899526&r1=1899525&r2=1899526&view=diff
==============================================================================
--- spamassassin/trunk/UPGRADE (original)
+++ spamassassin/trunk/UPGRADE Sun Apr  3 08:19:41 2022
@@ -174,6 +174,9 @@ Note for Users Upgrading to SpamAssassin
 
 - MIMEHeader: support matching ALL header, tflags range, tflags concat
 
+- Autolearn: add new tflags autolearn_header/autolearn_body. These can
+  force a rule to count as header or body points accordingly. (Bug 7907)
+
 Note for Users Upgrading to SpamAssassin 3.4.5
 ----------------------------------------------
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=1899526&r1=1899525&r2=1899526&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Sun Apr  3 08:19:41 2022
@@ -774,6 +774,7 @@ sub _get_autolearn_points {
   $self->{autolearn_force} = 0;
 
   foreach my $test (@{$self->{test_names_hit}}) {
+    my $force_type = '';
     # According to the documentation, noautolearn, userconf, and learn
     # rules are ignored for autolearning.
     if (exists $tflags->{$test}) {
@@ -794,6 +795,12 @@ sub _get_autolearn_points {
         #ADD RULE NAME TO LIST
         $self->{autolearn_force_names}.="$test,";
       }
+
+      # Bug 7907
+      local $1;
+      if ($tflags->{$test} =~ /\bautolearn_(body|header)\b/) {
+        $force_type = $1;
+      }
     }
 
     # ignore tests with 0 score (or undefined) in this scoreset
@@ -803,11 +810,11 @@ sub _get_autolearn_points {
     # Changed logic because in testing, I was getting both head and body. Bug 5503
     # Cleanup logic, Bug 7905/7906
     my $type = $self->_get_autolearn_testtype($conf->{test_types}->{$test});
-    if ($type eq 'head') {
+    if ($force_type eq 'header' || ($force_type eq '' && $type eq 'head')) {
       $self->{head_only_points} += $scores->{$test};
       dbg("learn: auto-learn: adding header points $scores->{$test} ($test)");
     }
-    elsif ($type eq 'body') {
+    elsif ($force_type eq 'body' || ($force_type eq '' && $type eq 'body')) {
       $self->{body_only_points} += $scores->{$test};
       dbg("learn: auto-learn: adding body points $scores->{$test} ($test)");
     }

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm?rev=1899526&r1=1899525&r2=1899526&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AutoLearnThreshold.pm Sun Apr  3 08:19:41 2022
@@ -105,7 +105,11 @@ Note: SpamAssassin requires at least 3 p
 points from the body to auto-learn as spam.  Therefore, the minimum
 working value for this option is 6.
 
-If the test option autolearn_force is set, the minimum value will 
+If test option C<autolearn_header> or C<autolearn_body> is set, points from
+that rule are forced to count as coming from header or body accordingly. 
+This can be useful for adjusting some meta rules.
+
+If the test option C<autolearn_force> is set, the minimum value will 
 remain at 6 points but there is no requirement that the points come
 from body and header rules.  This option is useful for autolearning
 with rules that are considered to be extremely safe indicators of