You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2004/04/16 06:59:35 UTC

svn commit: rev 10041 - incubator/spamassassin/trunk/lib/Mail/SpamAssassin

Author: felicity
Date: Thu Apr 15 21:59:34 2004
New Revision: 10041

Modified:
   incubator/spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm
   incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm
Log:
bug 3269: message parser needs to return mime boundary states for the MIME_MISSING_BOUNDARY rule to figure out if boundaries are missing

Modified: incubator/spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm
==============================================================================
--- incubator/spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm	(original)
+++ incubator/spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm	Thu Apr 15 21:59:34 2004
@@ -2552,7 +2552,6 @@
 
   # MIME status
   my $where = -1;		# -1 = start, 0 = nowhere, 1 = header, 2 = body
-  my %state;			# state of each MIME part
   my $qp_bytes = 0;		# total bytes in QP regions
   my $qp_count = 0;		# QP-encoded bytes in QP regions
   my @part_bytes;		# MIME part total bytes
@@ -2667,6 +2666,7 @@
   if ($qp_bytes) {
     $self->{mime_qp_ratio} = $qp_count / $qp_bytes;
   }
+
   if ($self->{mime_multipart_alternative}) {
     my $text;
     my $html;
@@ -2683,8 +2683,10 @@
       $self->{mime_multipart_ratio} = ($text / $html);
     }
   }
-  foreach my $str (keys %state) {
-    if ($state{$str} != 0) {
+
+  # Look to see if any multipart boundaries are not "balanced"
+  foreach my $val (values %{$self->{msg}->{mime_boundary_state}}) {
+    if ($val != 0) {
       $self->{mime_missing_boundary} = 1;
       last;
     }

Modified: incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm
==============================================================================
--- incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm	(original)
+++ incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm	Thu Apr 15 21:59:34 2004
@@ -85,6 +85,7 @@
 
   $self->{pristine_headers} =	'';
   $self->{pristine_body} =	'';
+  $self->{mime_boundary_state} = {};
 
   bless($self,$class);
 
@@ -375,7 +376,11 @@
     my $line;
     my $tmp_line = @{$body};
     for ($line=0; $line < $tmp_line; $line++) {
-      last if $body->[$line] =~ /^\-\-\Q$boundary\E$/;
+      if ($body->[$line] =~ /^\-\-\Q$boundary\E$/) {
+	# Make note that we found the opening boundary
+	$self->{mime_boundary_state}->{$boundary} = 1;
+        last;
+      }
     }
 
     # Found a boundary, ignore the preamble
@@ -416,7 +421,11 @@
         $self->parse_body( $msg, $part_msg, $p_boundary, $part_array, 0 );
       }
 
-      last if (defined $boundary && $line =~ /^\-\-\Q${boundary}\E\-\-$/);
+      if (defined $boundary && $line =~ /^\-\-\Q${boundary}\E\-\-$/) {
+	# Make a note that we've seen the end boundary
+	$self->{mime_boundary_state}->{$boundary}--;
+        last;
+      }
 
       # make sure we start with a new clean node
       $in_body  = 0;