@@ -887,6 +887,7 @@ sub winmail
887
887
my $type = unpack 'C', substr $data , $pos , 1;
888
888
return 0 unless defined $type && $type == ATTACHMENT; ++$pos ;
889
889
my $id = unpack 'V', substr $data , $pos , 4; $pos += 4;
890
+ ++$badtnef if $id == ATTACH_RENDDATA && @attachment && !exists $attachment ->{body};
890
891
push @attachment , $attachment = {} if $id == ATTACH_RENDDATA;
891
892
my $len = unpack 'V', substr $data , $pos , 4; $pos += 4;
892
893
++$badtnef , return 0 if $pos + $len > length $data ;
@@ -923,6 +924,7 @@ sub winmail
923
924
read_attribute_message_class();
924
925
do {} while read_message_attribute();
925
926
do {} while read_attachment_attribute();
927
+ ++$badtnef if @attachment && !exists $attachment ->{body};
926
928
return ($badtnef ) ? $m : map { newmail(%$_ ) } @attachment ;
927
929
}
928
930
@@ -945,6 +947,9 @@ my $pdftotext = find('pdftotext');
945
947
my $mktemp = find('mktemp');
946
948
paths() if exists $opt {'?'};
947
949
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);
948
953
my $force = exists $opt {f};
949
954
my $remove_word = (defined $antiword || $force ) && ! exists $opt {W};
950
955
my $remove_excel = (defined $xls2csv || $force ) && ! exists $opt {E};
@@ -987,7 +992,7 @@ formail(sub { <> }, sub
987
992
988
993
rmdir $tmp or system "rm -rf $tmp ";
989
994
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 } }
991
996
992
997
# Print paths to help applications then exit
993
998
@@ -1122,9 +1127,9 @@ sub textmail
1122
1127
# Remove images, audio, video, MS Windows executables, octet streams, application/*
1123
1128
1124
1129
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) ||
1128
1133
$remove_exe && mimetype($parts [$i ]) =~ /^application\/ octet-stream/ && filename($parts [$i ]) =~ /\. (?:@{[join '|', @exe ]})(?:\? =)?$/i ||
1129
1134
$remove_octet && mimetype($parts [$i ]) =~ /^application\/ octet-stream/ ||
1130
1135
$remove_application && mimetype($parts [$i ]) =~ /^application\/ /))
0 commit comments