From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 03E9B20179 for ; Fri, 17 Jun 2016 00:21:08 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] msg_iter: support read-only elements Date: Fri, 17 Jun 2016 00:21:08 +0000 Message-Id: <20160617002108.31320-1-e@80x24.org> List-Id: Apparently, it's possible to have read-only bodies in Email::MIME objects. Haven't gotten a chance to reliably reproduce it, though... --- lib/PublicInbox/MsgIter.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/MsgIter.pm b/lib/PublicInbox/MsgIter.pm index e0127ab..ef0d209 100644 --- a/lib/PublicInbox/MsgIter.pm +++ b/lib/PublicInbox/MsgIter.pm @@ -7,6 +7,7 @@ use warnings; use base qw(Exporter); our @EXPORT = qw(msg_iter); use Email::MIME; +use Scalar::Util qw(readonly); # Workaround Email::MIME versions without # commit dcef9be66c49ae89c7a5027a789bbbac544499ce @@ -36,7 +37,14 @@ sub msg_iter ($$) { @parts = (@sub, @parts); } else { if ($extra_nl) { - ${$part->{body}} .= $part->{mycrlf}; + my $lf = $part->{mycrlf}; + my $bref = $part->{body}; + if (readonly($$bref)) { + my $s = $$bref . $lf; + $part->{body} = \$s; + } else { + $$bref .= $lf; + } } $cb->($p); }