spamassassin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmcgr...@apache.org
Subject svn commit: r1243302 - /spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Bayes.pm
Date Sun, 12 Feb 2012 19:31:32 GMT
Author: kmcgrail
Date: Sun Feb 12 19:31:32 2012
New Revision: 1243302

URL: http://svn.apache.org/viewvc?rev=1243302&view=rev
Log:
Changing the way the msgid is calculated to remove last received and to also remove cr/lf
from the body. bug 5185.

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

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Bayes.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Bayes.pm?rev=1243302&r1=1243301&r2=1243302&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Bayes.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Bayes.pm Sun Feb 12 19:31:32 2012
@@ -946,24 +946,32 @@ sub get_msgid {
     push(@msgid, $msgid);
   }
 
-  # Use sha1_hex(Date:, last received: and top N bytes of body)
+  # Modified 2012-01-17  per bug 5185 to remove last received from msg_id calculation
+
+  # Use sha1_hex(Date: and top N bytes of body)
   # where N is MIN(1024 bytes, 1/2 of body length)
   #
   my $date = $msg->get_header("Date");
   $date = "None" if (!defined $date || $date eq ''); # No Date?
 
-  my @rcvd = $msg->get_header("Received");
-  my $rcvd = $rcvd[$#rcvd];
-  $rcvd = "None" if (!defined $rcvd || $rcvd eq ''); # No Received?
+  #Removed per bug 5185
+  #my @rcvd = $msg->get_header("Received");
+  #my $rcvd = $rcvd[$#rcvd];
+  #$rcvd = "None" if (!defined $rcvd || $rcvd eq ''); # No Received?
 
   # Make a copy since pristine_body is a reference ...
   my $body = join('', $msg->get_pristine_body());
+
   if (length($body) > 64) { # Small Body?
     my $keep = ( length $body > 2048 ? 1024 : int(length($body) / 2) );
     substr($body, $keep) = '';
   }
 
-  unshift(@msgid, sha1_hex($date."\000".$rcvd."\000".$body).'@sa_generated');
+  #Stripping all CR and LF so that testing midstream from MTA and post delivery don't 
+  #generate different id's simply because of LF<->CR<->CRLF changes.
+  $body =~ s/[\r\n]//g;
+
+  unshift(@msgid, sha1_hex($date."\000".$body).'@sa_generated');
 
   return wantarray ? @msgid : $msgid[0];
 }



Mime
View raw message