Skip to content

Commit 22b14bd

Browse files
committed
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
1 parent a8afa4f commit 22b14bd

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
20060525
2+
3+
- Fixed signal handler (wasn't calling exit after cleaning up!)
4+
- Better detection of broken/bizarre winmail.dat attachments
5+
- Detect image/audio/video attachments even when application/octet-stream
6+
17
20051129
28

39
- Fixed regexp for quoted-printable =xx values (was [0-9A-Fa-z])

textmail

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,7 @@ sub winmail
887887
my $type = unpack 'C', substr $data, $pos, 1;
888888
return 0 unless defined $type && $type == ATTACHMENT; ++$pos;
889889
my $id = unpack 'V', substr $data, $pos, 4; $pos += 4;
890+
++$badtnef if $id == ATTACH_RENDDATA && @attachment && !exists $attachment->{body};
890891
push @attachment, $attachment = {} if $id == ATTACH_RENDDATA;
891892
my $len = unpack 'V', substr $data, $pos, 4; $pos += 4;
892893
++$badtnef, return 0 if $pos + $len > length $data;
@@ -923,6 +924,7 @@ sub winmail
923924
read_attribute_message_class();
924925
do {} while read_message_attribute();
925926
do {} while read_attachment_attribute();
927+
++$badtnef if @attachment && !exists $attachment->{body};
926928
return ($badtnef) ? $m : map { newmail(%$_) } @attachment;
927929
}
928930
@@ -945,6 +947,9 @@ my $pdftotext = find('pdftotext');
945947
my $mktemp = find('mktemp');
946948
paths() if exists $opt{'?'};
947949
my @exe = qw(com exe pif dll ocx scr vbs js);
950+
my @image = qw(gif jpg jpeg jpe png bmp tiff tif jp2 jpf jpm);
951+
my @audio = qw(mp2 mp3 au aif wav ogg flac);
952+
my @video = qw(mpeg mpg mpe qt mov avi mj2);
948953
my $force = exists $opt{f};
949954
my $remove_word = (defined $antiword || $force) && ! exists $opt{W};
950955
my $remove_excel = (defined $xls2csv || $force) && ! exists $opt{E};
@@ -987,7 +992,7 @@ formail(sub { <> }, sub
987992
988993
rmdir $tmp or system "rm -rf $tmp";
989994
990-
BEGIN { $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub { rmdir $tmp or system "rm -rf $tmp" if defined $tmp } }
995+
BEGIN { $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub { rmdir $tmp or system "rm -rf $tmp" if defined $tmp; exit } }
991996
992997
# Print paths to help applications then exit
993998
@@ -1122,9 +1127,9 @@ sub textmail
11221127
# Remove images, audio, video, MS Windows executables, octet streams, application/*
11231128
11241129
if (!protected($parts[$i]) &&
1125-
($remove_images && mimetype($parts[$i]) =~ /^image\// ||
1126-
$remove_audio && mimetype($parts[$i]) =~ /^audio\// ||
1127-
$remove_video && mimetype($parts[$i]) =~ /^video\// ||
1130+
($remove_images && (mimetype($parts[$i]) =~ /^image\// || filename($parts[$i]) =~ /\.(?:@{[join '|', @image]})(?:\?=)?$/i) ||
1131+
$remove_audio && (mimetype($parts[$i]) =~ /^audio\// || filename($parts[$i]) =~ /\.(?:@{[join '|', @video]})(?:\?=)?$/i) ||
1132+
$remove_video && (mimetype($parts[$i]) =~ /^video\// || filename($parts[$i]) =~ /\.(?:@{[join '|', @audio]})(?:\?=)?$/i) ||
11281133
$remove_exe && mimetype($parts[$i]) =~ /^application\/octet-stream/ && filename($parts[$i]) =~ /\.(?:@{[join '|', @exe]})(?:\?=)?$/i ||
11291134
$remove_octet && mimetype($parts[$i]) =~ /^application\/octet-stream/ ||
11301135
$remove_application && mimetype($parts[$i]) =~ /^application\//))

0 commit comments

Comments
 (0)