about summary refs log tree commit homepage
path: root/lib/PublicInbox/MsgIter.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/MsgIter.pm')
-rw-r--r--lib/PublicInbox/MsgIter.pm8
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);
 }