Skip to content

Commit

Permalink
20060525
Browse files Browse the repository at this point in the history
    - Fixed signal handler (wasn't calling exit after cleaning up!)
    - Better detection of broken/bizarre winmail.dat attachments
    - Detect image/audio/video attachments even when application/octet-stream
  • Loading branch information
raforg committed May 25, 2006
1 parent a8afa4f commit 22b14bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
20060525

- Fixed signal handler (wasn't calling exit after cleaning up!)
- Better detection of broken/bizarre winmail.dat attachments
- Detect image/audio/video attachments even when application/octet-stream

20051129

- Fixed regexp for quoted-printable =xx values (was [0-9A-Fa-z])
Expand Down
13 changes: 9 additions & 4 deletions textmail
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,7 @@ sub winmail
my $type = unpack 'C', substr $data, $pos, 1;
return 0 unless defined $type && $type == ATTACHMENT; ++$pos;
my $id = unpack 'V', substr $data, $pos, 4; $pos += 4;
++$badtnef if $id == ATTACH_RENDDATA && @attachment && !exists $attachment->{body};
push @attachment, $attachment = {} if $id == ATTACH_RENDDATA;
my $len = unpack 'V', substr $data, $pos, 4; $pos += 4;
++$badtnef, return 0 if $pos + $len > length $data;
Expand Down Expand Up @@ -923,6 +924,7 @@ sub winmail
read_attribute_message_class();
do {} while read_message_attribute();
do {} while read_attachment_attribute();
++$badtnef if @attachment && !exists $attachment->{body};
return ($badtnef) ? $m : map { newmail(%$_) } @attachment;
}
Expand All @@ -945,6 +947,9 @@ my $pdftotext = find('pdftotext');
my $mktemp = find('mktemp');
paths() if exists $opt{'?'};
my @exe = qw(com exe pif dll ocx scr vbs js);
my @image = qw(gif jpg jpeg jpe png bmp tiff tif jp2 jpf jpm);
my @audio = qw(mp2 mp3 au aif wav ogg flac);
my @video = qw(mpeg mpg mpe qt mov avi mj2);
my $force = exists $opt{f};
my $remove_word = (defined $antiword || $force) && ! exists $opt{W};
my $remove_excel = (defined $xls2csv || $force) && ! exists $opt{E};
Expand Down Expand Up @@ -987,7 +992,7 @@ formail(sub { <> }, sub
rmdir $tmp or system "rm -rf $tmp";
BEGIN { $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub { rmdir $tmp or system "rm -rf $tmp" if defined $tmp } }
BEGIN { $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub { rmdir $tmp or system "rm -rf $tmp" if defined $tmp; exit } }
# Print paths to help applications then exit
Expand Down Expand Up @@ -1122,9 +1127,9 @@ sub textmail
# Remove images, audio, video, MS Windows executables, octet streams, application/*
if (!protected($parts[$i]) &&
($remove_images && mimetype($parts[$i]) =~ /^image\// ||
$remove_audio && mimetype($parts[$i]) =~ /^audio\// ||
$remove_video && mimetype($parts[$i]) =~ /^video\// ||
($remove_images && (mimetype($parts[$i]) =~ /^image\// || filename($parts[$i]) =~ /\.(?:@{[join '|', @image]})(?:\?=)?$/i) ||
$remove_audio && (mimetype($parts[$i]) =~ /^audio\// || filename($parts[$i]) =~ /\.(?:@{[join '|', @video]})(?:\?=)?$/i) ||
$remove_video && (mimetype($parts[$i]) =~ /^video\// || filename($parts[$i]) =~ /\.(?:@{[join '|', @audio]})(?:\?=)?$/i) ||
$remove_exe && mimetype($parts[$i]) =~ /^application\/octet-stream/ && filename($parts[$i]) =~ /\.(?:@{[join '|', @exe]})(?:\?=)?$/i ||
$remove_octet && mimetype($parts[$i]) =~ /^application\/octet-stream/ ||
$remove_application && mimetype($parts[$i]) =~ /^application\//))
Expand Down

0 comments on commit 22b14bd

Please sign in to comment.