From 1a6df0f901165156de64fd167ce48fd726954c05 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 15 Oct 2015 18:31:50 +0000 Subject: filter: fix handling of bad attachments Improve error messages and use a better regexp for detecting printable characters in attachments. --- lib/PublicInbox/Filter.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/Filter.pm b/lib/PublicInbox/Filter.pm index 01052d02..82baa9b9 100644 --- a/lib/PublicInbox/Filter.pm +++ b/lib/PublicInbox/Filter.pm @@ -151,7 +151,8 @@ sub strip_multipart { if (recheck_type_ok($part)) { push @keep, $part; } elsif ($filter) { - $filter->reject(TEXT_ONLY); + $filter->reject("Bad attachment: $part_type ". + TEXT_ONLY); } else { $rejected++; } @@ -162,8 +163,10 @@ sub strip_multipart { if ($rejected == 0 && !@html) { push @keep, $part; } + } elsif ($filter) { + $filter->reject("unacceptable mime-type: $part_type ". + TEXT_ONLY); } else { - $filter->reject(TEXT_ONLY) if $filter; # reject everything else, including non-PGP signatures $rejected++; } @@ -232,8 +235,7 @@ sub replace_body { sub recheck_type_ok { my ($part) = @_; my $s = $part->body; - ((length($s) < 0x10000) && - ($s =~ /\A([\P{XPosixPrint}\f\n\r\t]+)\z/)) + ((length($s) < 0x10000) && ($s =~ /\A([[:print:]\s]+)\z/s)); } 1; -- cgit v1.2.3-24-ge0c7