spamassassin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j.@apache.org
Subject svn commit: rev 10399 - incubator/spamassassin/trunk/masses
Date Thu, 29 Apr 2004 02:56:01 GMT
Author: jm
Date: Wed Apr 28 19:56:01 2004
New Revision: 10399

Modified:
   incubator/spamassassin/trunk/masses/mass-check
Log:
--deencap didn't deal with the case where a local scanner overwrote the remote scanner's X-Spam-Checker-Version
header.  fix by grovelling through the body parts :(

Modified: incubator/spamassassin/trunk/masses/mass-check
==============================================================================
--- incubator/spamassassin/trunk/masses/mass-check	(original)
+++ incubator/spamassassin/trunk/masses/mass-check	Wed Apr 28 19:56:01 2004
@@ -247,7 +247,7 @@
   my (undef, $id, $time, $dataref) = @_;
   my $out;
 
-  my $ma = $spamtest->parse($dataref);
+  my $ma = $spamtest->parse($dataref, 1);
 
   # remove SpamAssassin markup, if present and the mail was spam
   my $stat = $ma->get_header("X-Spam-Status");
@@ -353,24 +353,32 @@
   return $out;
 }
 
+# ick.  We have to go grovelling through the body parts to see if a message
+# is a report_safe-marked-up message, because a local scanner will overwrite
+# any remote scanner's X-Spam-Checker-Version header.
+#
 sub message_should_be_deencapped {
   my ($ma) = @_;
 
-  my $vers = $ma->get_header("X-Spam-Checker-Version");
-  return 1 if (!$vers);     # no header? probably not SpamAssassin encapsulation.
-  # return 1 so that old versions of SpamAssassin encapping are removed
-
-  $vers =~ s/\s+/ /gs;
-  if ($vers !~ / on (\S+)\s*$/) {
-    # X-Spam-Checker-Version has no hostname.
-    # always remove the markup, it's probably not an encapsulated message
-    # in that case
-    return 1;
-  }
+  if (scalar @{$ma->{body_parts}} > 0) {
+    my $firstpart = $ma->{body_parts}->[0];
+    if (!$firstpart->{headers}->{'content-type'}
+        || $firstpart->{headers}->{'content-type'} ne 'text/plain')
+    {
+      return 0;     # not a 'report_safe' encapsulation
+    }
 
-  my $hname = $1;
-  if ($hname =~ /$opt_deencap/io) {
-    return 1;
+    if (scalar @{$firstpart->{raw}} < 3) { return 0; } # too short to be a report
+
+    # grab first 2 lines
+    my $text = $firstpart->{raw}->[0] . $firstpart->{raw}->[1];
+    $text =~ s/\s+/ /gs;
+    if ($text =~ /^Spam detection software, running on the system \"(\S+)\"/) {
+      my $hname = $1;
+      if ($hname =~ /$opt_deencap/io) {
+        return 1;
+      }
+    }
   }
 
   return 0;     # a different host marked it up.  pass it through!

Mime
View raw message