diff options
author | Eric Wong <e@80x24.org> | 2016-05-19 10:23:28 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-05-19 20:53:21 +0000 |
commit | 68a85e8dd7d01578a10a4bfa24818cfe53200690 (patch) | |
tree | 9615529d881897a9f12815e0901e78eaf4a4f2e3 /lib/PublicInbox | |
parent | 78042ed9abb2bbe9783adcc485365a8672e4b36f (diff) | |
download | public-inbox-68a85e8dd7d01578a10a4bfa24818cfe53200690.tar.gz |
Email::MIME >= 1.923 and < 1.935 would drop too many newlines in attachments. This would lead to ugly text files without a proper trailing newline if using quoted-printable, 7bit, or 8bit. Attachments encoded with base64 were not affected. These versions of Email::MIME are widely available in Debian 8 (Jessie) and even Ubuntu LTS distros so we will need to support this workaround for a while.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/MsgIter.pm | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/PublicInbox/MsgIter.pm b/lib/PublicInbox/MsgIter.pm index d0dd82fb..e0127ab9 100644 --- a/lib/PublicInbox/MsgIter.pm +++ b/lib/PublicInbox/MsgIter.pm @@ -6,6 +6,16 @@ use strict; use warnings; use base qw(Exporter); our @EXPORT = qw(msg_iter); +use Email::MIME; + +# Workaround Email::MIME versions without +# commit dcef9be66c49ae89c7a5027a789bbbac544499ce +# ("removing all trailing newlines was too much") +# This is necessary for Debian jessie +my $bad = 1.923; +my $good = 1.935; +my $ver = $Email::MIME::VERSION; +my $extra_nl = 1 if ($ver >= $bad && $ver < $good); # Like Email::MIME::walk_parts, but this is: # * non-recursive @@ -25,6 +35,9 @@ sub msg_iter ($$) { @sub = map { [ $_, $depth, @idx, ++$i ] } @sub; @parts = (@sub, @parts); } else { + if ($extra_nl) { + ${$part->{body}} .= $part->{mycrlf}; + } $cb->($p); } } |