diff options
author | Eric Wong <e@80x24.org> | 2021-03-10 19:45:39 -0600 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-03-12 02:18:15 +0000 |
commit | 0ec3ddaeea0e3eac3f4e686cd4383840414fbc4d (patch) | |
tree | 62872151aa17cecbbc1f055f907678d625e209b4 /lib/PublicInbox | |
parent | 7534692cd42797deeb9142598e031ca3184951cf (diff) | |
download | public-inbox-0ec3ddaeea0e3eac3f4e686cd4383840414fbc4d.tar.gz |
Some poorly-configured MUAs will send application/octet-stream even for text-only attachments. We can't make expect all MUAs are configured with proper MIME types, and there is plenty of historical mail that falls into this unfortunate criteria. v2: simplify the check and ensures returned text is Perl "utf8"
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/MsgIter.pm | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/PublicInbox/MsgIter.pm b/lib/PublicInbox/MsgIter.pm index c503eb98..9c6581cc 100644 --- a/lib/PublicInbox/MsgIter.pm +++ b/lib/PublicInbox/MsgIter.pm @@ -84,6 +84,14 @@ sub msg_part_text ($$) { # If forcing charset=UTF-8 failed, # caller will warn further down... $s = $part->body if $@; + } elsif ($err && $ct =~ m!\bapplication/octet-stream\b!i) { + # Some unconfigured/poorly-configured MUAs will set + # application/octet-stream even for all text attachments. + # Try to see if it's printable text that we can index + # and display: + $s = $part->body; + utf8::decode($s); + undef($s =~ /[^\p{XPosixPrint}\s]/s ? $s : $err); } ($s, $err); } |