-# Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# read-only utilities for Email::MIME
# 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);
}