about summary refs log tree commit homepage
path: root/lib/PublicInbox/MsgIter.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-06-16 22:45:24 +0000
committerEric Wong <e@80x24.org>2016-06-17 00:19:31 +0000
commitc1de840e23416eea63739b21995b07b2e8a1e9ac (patch)
treece2cc409be5b42103704f59951542ecf09d83b1d /lib/PublicInbox/MsgIter.pm
parentd7cd35c27975dc6a757db9891b09a8115c10a691 (diff)
downloadpublic-inbox-c1de840e23416eea63739b21995b07b2e8a1e9ac.tar.gz
Apparently, it's possible to have read-only bodies in
Email::MIME objects.  Haven't gotten a chance to reliably
reproduce it, though...
Diffstat (limited to 'lib/PublicInbox/MsgIter.pm')
-rw-r--r--lib/PublicInbox/MsgIter.pm10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/PublicInbox/MsgIter.pm b/lib/PublicInbox/MsgIter.pm
index e0127ab9..ef0d209f 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);
                         }