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 2007/01/04 21:24:33 UTC

svn commit: r492719 - /spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm

Author: felicity
Date: Thu Jan  4 12:24:32 2007
New Revision: 492719

URL: http://svn.apache.org/viewvc?view=rev&rev=492719
Log:
bug 5051: deal with empty message/* parts appropriately

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm?view=diff&rev=492719&r1=492718&r2=492719
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm Thu Jan  4 12:24:32 2007
@@ -615,38 +615,42 @@
         # Just decode the part, but we don't care about the result here.
         $toparse->[0]->decode(0);
 
-	# Ok, so this part is still semi-recursive, since M::SA::Message calls
-	# M::SA::Message, but we don't subparse the new message, and pull a
-	# sneaky "steal our child's queue" maneuver to deal with it on our own
-	# time.  Reference the decoded array directly since it's faster.
-	# 
-        my $msg_obj = Mail::SpamAssassin::Message->new({
-    	  message	=>	$toparse->[0]->{'decoded'},
-	  parsenow	=>	0,
-	  normalize	=>	$self->{normalize},
-	  subparse	=>	$toparse->[3]-1,
-	  });
+	# bug 5051: sometimes message/* parts have no content, and we get
+	# stuck waiting for STDIN, which is bad. :(
+        if ($toparse->[0]->{'decoded'}) {
+	  # Ok, so this part is still semi-recursive, since M::SA::Message calls
+	  # M::SA::Message, but we don't subparse the new message, and pull a
+	  # sneaky "steal our child's queue" maneuver to deal with it on our own
+	  # time.  Reference the decoded array directly since it's faster.
+	  # 
+          my $msg_obj = Mail::SpamAssassin::Message->new({
+    	    message	=>	$toparse->[0]->{'decoded'},
+	    parsenow	=>	0,
+	    normalize	=>	$self->{normalize},
+	    subparse	=>	$toparse->[3]-1,
+	    });
 
-	# Add the new message to the current node
-        $toparse->[0]->add_body_part($msg_obj);
+	  # Add the new message to the current node
+          $toparse->[0]->add_body_part($msg_obj);
 
-	# now this is the sneaky bit ... steal the sub-message's parse_queue
-	# and add it to ours.  then we'll handle the sub-message in our
-	# normal loop and get all the glory.  muhaha.  :)
-	push(@{$self->{'parse_queue'}}, @{$msg_obj->{'parse_queue'}});
-	delete $msg_obj->{'parse_queue'};
+	  # now this is the sneaky bit ... steal the sub-message's parse_queue
+	  # and add it to ours.  then we'll handle the sub-message in our
+	  # normal loop and get all the glory.  muhaha.  :)
+	  push(@{$self->{'parse_queue'}}, @{$msg_obj->{'parse_queue'}});
+	  delete $msg_obj->{'parse_queue'};
 
-	# Ok, we've subparsed, so go ahead and remove the raw and decoded
-	# data because we won't need them anymore (the tree under this part
-	# will have that data)
-	if (ref $toparse->[0]->{'raw'} eq 'GLOB') {
-	  # Make sure we close it if it's a temp file -- Bug 5166
-	  close ($toparse->[0]->{'raw'});
-	}
+	  # Ok, we've subparsed, so go ahead and remove the raw and decoded
+	  # data because we won't need them anymore (the tree under this part
+	  # will have that data)
+	  if (ref $toparse->[0]->{'raw'} eq 'GLOB') {
+	    # Make sure we close it if it's a temp file -- Bug 5166
+	    close ($toparse->[0]->{'raw'});
+	  }
 
-	delete $toparse->[0]->{'raw'};
+	  delete $toparse->[0]->{'raw'};
 	  
-	delete $toparse->[0]->{'decoded'};
+	  delete $toparse->[0]->{'decoded'};
+        }
       }
     }
   }