user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] filter: handle missing Content-Type
@ 2015-01-11 10:46 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-01-11 10:46 UTC (permalink / raw)
  To: meta; +Cc: Eric Wong

Some mailers may omit the Content-Type header entirely,
so do detection and try to get the message through.
---
 lib/PublicInbox/Filter.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/Filter.pm b/lib/PublicInbox/Filter.pm
index 929a8ff..6862bb6 100644
--- a/lib/PublicInbox/Filter.pm
+++ b/lib/PublicInbox/Filter.pm
@@ -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
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-01-11 10:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-11 10:46 [PATCH] filter: handle missing Content-Type Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).