I found that this line of my patch to fix the "MIME null block" problem was 
causing an infinite loop sometimes:

        my $boundary = "--$1";

Since it's used in a regular expression, if the boundrary string has regexp 
meta-characters in it, things will get messed up.  Specifically, if the 
bounary has something between parens in it, it will go into an infinite loop. 
Here is a patch to my original patch to solve the


--- PerMsgStatus.pm-old Wed Mar  6 17:23:58 2002
+++ PerMsgStatus.pm     Wed Mar  6 16:06:31 2002
@@ -408,7 +408,7 @@
       # peel off the MIME header for the main part of the message,
       # stick in the report, then put the MIME header back in front,
       # so that the report is *after* the MIME header.
-      my $boundary = "--$1";
+      my $boundary = "--" . quotemeta($1);
       my @main_part = ();
 
       push(@main_part, shift(@{$lines})) while ($lines->[0] !~ /^$boundary/);


And here is the whole patch, all over again, with the anti-infinite-loop fix:

Index: PerMsgStatus.pm
===================================================================
RCS file: 
/cvsroot/spamassassin/spamassassin/lib/Mail/SpamAssassin/PerMsgStatus.pm,v
retrieving revision 1.80
diff -u -3 -p -r1.80 PerMsgStatus.pm
--- PerMsgStatus.pm     6 Mar 2002 11:23:35 -0000       1.80
+++ PerMsgStatus.pm     7 Mar 2002 01:29:54 -0000
@@ -403,8 +403,27 @@ sub rewrite_as_spam {
       $rep =~ s/=/=3D/gs;               # quote the = chars
     }
 
-    unshift (@{$lines}, split (/$/, $rep));
-    $lines->[0] =~ s/\n//;
+    if ($self->{msg}->get_header ('Content-Type') =~ /boundary="(.*)"/) {
+      # Deal with MIME "null block".  If this is a multipart MIME mail,
+      # peel off the MIME header for the main part of the message,
+      # stick in the report, then put the MIME header back in front,
+      # so that the report is *after* the MIME header.
+      my $boundary = "--" . quotemeta($1);
+      my @main_part = ();
+
+      push(@main_part, shift(@{$lines})) while ($lines->[0] !~ /^$boundary/);
+      push(@main_part, shift(@{$lines})) while ($lines->[0] !~ /^$/);
+      push(@main_part, shift(@{$lines}));
+
+      unshift (@{$lines}, split (/$/, $rep));
+      $lines->[0] =~ s/\n//;
+      unshift (@{$lines}, @main_part);
+    }
+    else {
+      unshift (@{$lines}, split (/$/, $rep));
+      $lines->[0] =~ s/\n//;
+    }
+
     $self->{msg}->replace_body ($lines);
   }

-- 
Visit http://dmoz.org, the world's   | Give a man a match, and he'll be warm
largest human edited web directory.  | for a minute, but set him on fire, and
                                     | he'll be warm for the rest of his life.
[EMAIL PROTECTED]  ICQ: 132152059 |

_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to