]> Sergey Matveev's repositories - public-inbox.git/commitdiff
PublicInbox::Import Smuggle a raw message into add
authorEric W. Biederman <ebiederm@xmission.com>
Tue, 15 Jan 2019 22:36:42 +0000 (16:36 -0600)
committerEric Wong <e@80x24.org>
Tue, 15 Oct 2019 20:22:44 +0000 (20:22 +0000)
I don't trust the MIME type to not munge my email messages in horrible
ways upon occasion.  Therefore  allow for passing in the raw message
value instead of trusting the mime object to preserve it.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
[ew: use "//" from Perl 5.10+ for defined check]

lib/PublicInbox/Import.pm

index 137b2b7800c403c188db050f0dd1df3a5583b28a..e1f48771bd629c6dfe37b15b19138681b5bd1b2a 100644 (file)
@@ -394,16 +394,16 @@ sub add {
        }
 
        my $blob = $self->{mark}++;
-       my $str = $mime->as_string;
-       my $n = length($str);
+       my $raw_email = $mime->{-public_inbox_raw} // $mime->as_string;
+       my $n = length($raw_email);
        $self->{bytes_added} += $n;
        print $w "blob\nmark :$blob\ndata ", $n, "\n" or wfail;
-       print $w $str, "\n" or wfail;
+       print $w $raw_email, "\n" or wfail;
 
        # v2: we need this for Xapian
        if ($self->{want_object_info}) {
                my $oid = $self->get_mark(":$blob");
-               $self->{last_object} = [ $oid, $n, \$str ];
+               $self->{last_object} = [ $oid, $n, \$raw_email ];
        }
        my $ref = $self->{ref};
        my $commit = $self->{mark}++;