From 68a85e8dd7d01578a10a4bfa24818cfe53200690 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 19 May 2016 10:23:28 +0000 Subject: msg_iter: workaround broken Email::MIME versions 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. --- lib/PublicInbox/MsgIter.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/PublicInbox/MsgIter.pm') 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); } } -- cgit v1.2.3-24-ge0c7