|
[SACVS] CVS: spamassassin/lib/Mail/SpamAssassin MIME.pm,1.2,1.3: msg#00113mail.spam.spamassassin.cvs
Update of /cvsroot/spamassassin/spamassassin/lib/Mail/SpamAssassin In directory sc8-pr-cvs1:/tmp/cvs-serv2010/lib/Mail/SpamAssassin Modified Files: MIME.pm Log Message: a bit more code cleanup Index: MIME.pm =================================================================== RCS file: /cvsroot/spamassassin/spamassassin/lib/Mail/SpamAssassin/MIME.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -b -w -u -d -r1.2 -r1.3 --- MIME.pm 24 Sep 2003 19:30:32 -0000 1.2 +++ MIME.pm 24 Sep 2003 21:33:32 -0000 1.3 @@ -2,17 +2,24 @@ package Mail::SpamAssassin::MIME; use strict; -use MIME::Base64 qw(encode_base64); +use MIME::Base64; +use Mail::SpamAssassin; sub new { - bless { + my $class = shift; + $class = ref($class) || $class; + + my $self = { headers => {}, raw_headers => {}, body_parts => [], attachments => [], - }, - shift; + }; + + bless($self,$class); + + $self; } sub header { @@ -55,6 +62,10 @@ my $self = shift; my $key = lc(shift); + # Trim whitespace off of the header keys + $key =~ s/^\s+//; + $key =~ s/\s+$//; + if (wantarray) { return unless exists $self->{raw_headers}{$key}; return @{ $self->{raw_headers}{$key} }; @@ -66,15 +77,16 @@ } sub add_body_part { - my $self = shift; - my ( $type, $decoded, $raw, $boundary ) = @_; + my($self, $raw_type, $decoded, $raw, $boundary) = @_; $boundary ||= ''; + my $type = $raw_type; $type ||= 'text/plain'; $type =~ s/;.*$//; # strip everything after first semi-colon $type =~ s/[^a-zA-Z\/]//g; # strip inappropriate chars my $part = { type => $type, + raw_type => $raw_type, decoded => $decoded, raw => $raw, boundary => $boundary, @@ -84,13 +96,17 @@ } sub add_attachment { - my $self = shift; - my ( $type, $lines, $name, $raw, $boundary ) = @_; + my($self, $raw_type, $decoded, $name, $raw, $boundary) = @_; + my $type = $raw_type; + $type ||= 'text/plain'; + $type =~ s/;.*$//; # strip everything after first semi-colon + $type =~ s/[^a-zA-Z\/]//g; # strip inappropriate chars push @{ $self->{attachments} }, { filename => $name, type => $type, - decoded => $lines, + raw_type => $raw_type, + decoded => $decoded, raw => $raw, boundary => $boundary, }; @@ -137,6 +153,8 @@ my $self = shift; return scalar @{ $self->{attachments} }; } + +sub dbg { Mail::SpamAssassin::dbg (@_); } 1; __END__ ------------------------------------------------------- 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/lib/Mail/SpamAssassin/MIME Parser.pm,1.1,1.2: 00113, Theo Van Dinter |
|---|---|
| Next by Date: | [SACVS] CVS: spamassassin/lib/Mail/SpamAssassin/MIME Parser.pm,1.2,1.3: 00113, Theo Van Dinter |
| Previous by Thread: | [SACVS] CVS: spamassassin/lib/Mail/SpamAssassin/MIME Parser.pm,1.1,1.2i: 00113, Theo Van Dinter |
| Next by Thread: | [SACVS] CVS: spamassassin/lib/Mail/SpamAssassin/MIME Parser.pm,1.2,1.3: 00113, Theo Van Dinter |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |