X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FMsgIter.pm;h=9c6581cc9dd63415a32a0a8f59bafae1cdb2b86d;hb=0ec3ddaeea0e3eac3f4e686cd4383840414fbc4d;hp=5ec2a4d9c7f1d3e06f76d4c4abb639ddacb00ac4;hpb=e60231148eb604a379033c69e8c4494eb1753783;p=public-inbox.git diff --git a/lib/PublicInbox/MsgIter.pm b/lib/PublicInbox/MsgIter.pm index 5ec2a4d9..9c6581cc 100644 --- a/lib/PublicInbox/MsgIter.pm +++ b/lib/PublicInbox/MsgIter.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2020 all contributors +# Copyright (C) 2016-2021 all contributors # License: AGPL-3.0+ # read-only utilities for Email::MIME @@ -34,7 +34,7 @@ sub em_each_part ($$;$$) { } } } else { - $cb->([$mime, 0, 0], $cb_arg); + $cb->([$mime, 0, 1], $cb_arg); } } @@ -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); }