diff options
author | Eric Wong <e@yhbt.net> | 2020-05-07 21:05:56 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-05-09 08:59:10 +0000 |
commit | b2f2d28e20f7bf9e7234d3134ec91cd9549001b1 (patch) | |
tree | 0367014aee3db9e396304ee2e3e2a71efe78c3b2 | |
parent | 0283273a14e1871955f6a9132f4f3f7884ec8a3f (diff) | |
download | public-inbox-b2f2d28e20f7bf9e7234d3134ec91cd9549001b1.tar.gz |
This improves Email::MIME compatibility when running xt/cmp-msgview.t on some GPG-signed messages. Its usefulness is dubious in the long term and this patch may be reverted down the line.
-rw-r--r-- | lib/PublicInbox/Eml.pm | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/PublicInbox/Eml.pm b/lib/PublicInbox/Eml.pm index 1adaff04..4508bd84 100644 --- a/lib/PublicInbox/Eml.pm +++ b/lib/PublicInbox/Eml.pm @@ -131,8 +131,12 @@ sub mp_descend ($$) { # Cut at the the first epilogue, not subsequent ones. # *sigh* just the regexp match alone seems to bump RSS by # length($$bdy) on a ~30M string: - $$bdy =~ /((?:\r?\n)?^--$bnd--[ \t]*\r?$)/gsm and + my $epilogue_missing; + if ($$bdy =~ /((?:\r?\n)?^--$bnd--[ \t]*\r?$)/gsm) { substr($$bdy, pos($$bdy) - length($1)) = ''; + } else { + $epilogue_missing = 1; + } # *Sigh* split() doesn't work in-place and return CoW strings # because Perl wants to "\0"-terminate strings. So split() @@ -150,6 +154,10 @@ sub mp_descend ($$) { if (@parts) { # the usual path if we got this far: undef $bdy; # release memory ASAP if $nr > 0 + + # compatibility with Email::MIME + $parts[-1] =~ s/\n\r?\n\z/\n/s if $epilogue_missing; + @parts = grep /[^ \t\r\n]/s, @parts; # ignore empty parts # Keep "From: someone..." from preamble in old, |