logo       

[SACVS] CVS: spamassassin/lib/Mail/SpamAssassin MIME.pm,1.2,1.3: msg#00113

mail.spam.spamassassin.cvs

Subject: [SACVS] CVS: spamassassin/lib/Mail/SpamAssassin MIME.pm,1.2,1.3

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>
Google Custom Search

News | FAQ | advertise