]> Sergey Matveev's repositories - public-inbox.git/commitdiff
filter: handle missing Content-Type
authorEric Wong <e@80x24.org>
Sun, 11 Jan 2015 08:54:25 +0000 (08:54 +0000)
committerEric Wong <e@80x24.org>
Sun, 11 Jan 2015 08:57:03 +0000 (08:57 +0000)
Some mailers may omit the Content-Type header entirely,
so do detection and try to get the message through.

lib/PublicInbox/Filter.pm

index 929a8ffc5af34acf77a434e8dab249578d96b03f..6862bb68b82d27bcd66009cafeaa8aa50dfb2585 100644 (file)
@@ -129,7 +129,7 @@ sub strip_multipart {
                        return;
                }
 
-               my $part_type = $part->content_type;
+               my $part_type = $part->content_type || '';
                if ($part_type =~ m!\btext/plain\b!i) {
                        push @keep, $part;
                } elsif ($part_type =~ $MIME_HTML) {
@@ -140,7 +140,8 @@ sub strip_multipart {
                        # help with.
 
                        push @keep, $part;
-               } elsif ($part_type =~ m!\Aapplication/octet-stream\z!i) {
+               } elsif ($part_type eq '' ||
+                        $part_type =~ m!\Aapplication/octet-stream\z!i) {
                        # unfortunately, some mailers don't set correct types,
                        # let messages of unknown type through but do not
                        # change the sender-specified type