Mailing List Archive

svn commit: r440256 - in /spamassassin/trunk/lib/Mail/SpamAssassin: Message.pm Message/Node.pm
Author: felicity
Date: Mon Sep 4 21:37:35 2006
New Revision: 440256

URL: http://svn.apache.org/viewvc?view=rev&rev=440256
Log:
If a message part is subparsed, properly handle the fact that the part is not a leaf node (remove raw and decoded data)

Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.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=440256&r1=440255&r2=440256
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm Mon Sep 4 21:37:35 2006
@@ -586,30 +586,35 @@
$self->_parse_normal($toparse);

if ($toparse->[0]->{'type'} =~ /^message\b/i && ($toparse->[3] > 0)) {
- # Get the part ready...
- my $message = $toparse->[0]->decode();
+ # 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.
- if ($message) {
- my $msg_obj = Mail::SpamAssassin::Message->new({
- message => $message,
- parsenow => 0,
- normalize => $self->{normalize},
- subparse => $toparse->[3]-1,
- });
+ # 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)
+ delete $toparse->[0]->{'raw'};
+ delete $toparse->[0]->{'decoded'};
}
}
}

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm?view=diff&rev=440256&r1=440255&r2=440256
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm Mon Sep 4 21:37:35 2006
@@ -271,6 +271,12 @@
my($self, $bytes) = @_;

if ( !exists $self->{'decoded'} ) {
+ # Someone is looking for a decoded part where there is no raw data
+ # (multipart or subparsed message, etc.) Just return undef.
+ if (!exists $self->{'raw'}) {
+ return undef;
+ }
+
my $encoding = lc $self->header('content-transfer-encoding') || '';

if ( $encoding eq 'quoted-printable' ) {