|
[SACVS] CVS: spamassassin/lib/Mail/SpamAssassin/MIME Parser.pm,1.4,1.5: msg#00121mail.spam.spamassassin.cvs
Update of /cvsroot/spamassassin/spamassassin/lib/Mail/SpamAssassin/MIME In directory sc8-pr-cvs1:/tmp/cvs-serv7293/lib/Mail/SpamAssassin/MIME Modified Files: Parser.pm Log Message: more mime work Index: Parser.pm =================================================================== RCS file: /cvsroot/spamassassin/spamassassin/lib/Mail/SpamAssassin/MIME/Parser.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -b -w -u -d -r1.4 -r1.5 --- Parser.pm 24 Sep 2003 22:01:12 -0000 1.4 +++ Parser.pm 25 Sep 2003 03:38:04 -0000 1.5 @@ -141,32 +141,26 @@ } else { dbg("Regular attachment\n"); - $self->decode_attachment( $msg, $_msg, $boundary, $body ); + $self->decode_body( $msg, $_msg, $boundary, $body ); } if ( !$msg->body() ) { dbg("No message body found. Reparsing as blank.\n"); - my $part_array = []; my $part_msg = Mail::SpamAssassin::MIME->new(); - $self->decode_body( $msg, $part_msg, $boundary, $part_array ); + $self->decode_body( $msg, $part_msg, $boundary, [] ); } } sub parse_multipart_alternate { my($self, $msg, $_msg, $boundary, $body ) = @_; - my $preamble = ''; - dbg("m/a got boundary: $boundary\n"); - # extract preamble (normally contains "This message is in Multipart/MIME format") + # ignore preamble per RFC 1521 while ( my $line = shift @{$body} ) { last if $line =~ /^\-\-\Q$boundary\E$/; - $preamble .= $line; } - dbg("preamble: [[$preamble]]\n"); - my $in_body = 0; my $header; @@ -188,14 +182,7 @@ if ( $part_array->[ scalar @{$part_array} - 1 ] eq '' ); } - # assume body part if it's text - if ( $part_msg->header('content-type') =~ /^text/i ) { $self->decode_body( $msg, $part_msg, $boundary, $part_array ); - } - else { - dbg("Likely virus?\n"); - $self->decode_attachment( $msg, $part_msg, $boundary, $part_array ); - } last if $line =~ /^\-\-\Q$boundary\E\-\-$/; $in_body = 0; $part_msg = Mail::SpamAssassin::MIME->new(); @@ -237,16 +224,12 @@ my($self, $msg, $_msg, $boundary, $body) = @_; dbg("m/m Got boundary: $boundary\n"); - my $preamble = ''; - # extract preamble (normally contains "This message is in Multipart/MIME format") + # ignore preamble per RFC 1521 while ( my $line = shift @{$body} ) { last if $line =~ /^\-\-\Q$boundary\E$/; - $preamble .= $line; } - dbg("Extracted preamble: [[$preamble]]\n"); - my $part_msg = Mail::SpamAssassin::MIME->new(); # just used for headers storage my $in_body = 0; @@ -317,18 +300,14 @@ $self->decode_body( $msg, $_msg, $boundary, $body ); } -use File::Path qw(rmtree); - sub _decode_header { my ( $encoding, $cte, $data ) = @_; if ( $cte eq 'B' ) { - # base 64 encoded return MIME::Base64::decode_base64($data); } elsif ( $cte eq 'Q' ) { - # quoted printable return MIME::QuotedPrint::decode_qp($data); } @@ -352,21 +331,20 @@ sub decode_body { my($self, $msg, $part_msg, $boundary, $body ) = @_; - my ( $type, $content ) = $self->decode( $part_msg, $body ); - - dbg("got body: $type\n"); - - $msg->add_body_part( $type, $content, $body, $boundary ); -} - -sub decode_attachment { - my($self, $msg, $part_msg, $boundary, $body ) = @_; - dbg("decoding attachment\n"); my ( $type, $content, $filename ) = $self->decode( $part_msg, $body ); - $msg->add_attachment( $type, $content, $filename, $body, $boundary ); + my $opts = { + decoded => $content, + raw => $body, + boundary => $boundary, + headers => $part_msg->{headers}, + raw_headers => $part_msg->{raw_headers}, + }; + $opts->{name} = $filename if ( $filename ); + + $msg->add_body_part( $type, $opts ); } sub decode { ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [SACVS] CVS: spamassassin/t db_awl_path.t,1.5,1.6 db_based_whitelist.t,1.8,1.9 db_based_whitelist_ips.t,1.4,1.5 whitelist_addrs.t,1.2,1.3: 00121, Daniel Quinlan |
|---|---|
| Next by Date: | [SACVS] CVS: spamassassin/lib/Mail/SpamAssassin MIME.pm,1.3,1.4: 00121, Theo Van Dinter |
| Previous by Thread: | [SACVS] CVS: spamassassin/t db_awl_path.t,1.5,1.6 db_based_whitelist.t,1.8,1.9 db_based_whitelist_ips.t,1.4,1.5 whitelist_addrs.t,1.2,1.3i: 00121, Daniel Quinlan |
| Next by Thread: | [SACVS] CVS: spamassassin/lib/Mail/SpamAssassin MIME.pm,1.3,1.4: 00121, Theo Van Dinter |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |