about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-10-15 18:31:50 +0000
committerEric Wong <e@80x24.org>2015-10-15 18:31:50 +0000
commit1a6df0f901165156de64fd167ce48fd726954c05 (patch)
tree45958904f0e529efbc5776f12e2377e5c24a22e9 /lib
parent2d5202a04db9d4c2db5490270e698207dfb918bf (diff)
downloadpublic-inbox-1a6df0f901165156de64fd167ce48fd726954c05.tar.gz
Improve error messages and use a better regexp for detecting
printable characters in attachments.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/Filter.pm10
1 files changed, 6 insertions, 4 deletions
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;