]> Sergey Matveev's repositories - public-inbox.git/commitdiff
inbox: ensure we do not show leading "From " lines
authorEric Wong <e@80x24.org>
Sun, 26 Jun 2016 23:36:36 +0000 (23:36 +0000)
committerEric Wong <e@80x24.org>
Sun, 26 Jun 2016 23:36:36 +0000 (23:36 +0000)
Some messages will be misimported due to an old bug,
clean them up and ensure we do not propagate the mistake.

Followup-to: a0c07cba0e5d ("mda: drop leading "From " lines again")
lib/PublicInbox/Inbox.pm
lib/PublicInbox/SearchIdx.pm

index 34191fc79508f04ff9ce00cc3782333dd1c033bf..87c2c9fcdb57c14a50f625192b36a344abdc8ffe 100644 (file)
@@ -99,7 +99,9 @@ sub nntp_usable {
 sub msg_by_path ($$;$) {
        my ($self, $path, $ref) = @_;
        # TODO: allow other refs:
-       git($self)->cat_file('HEAD:'.$path, $ref);
+       my $str = git($self)->cat_file('HEAD:'.$path, $ref);
+       $$str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s;
+       $str;
 }
 
 sub msg_by_mid ($$;$) {
index 58eccc1a2d67241ed273e940fee0d1fb2b27c51d..c2bf9a2ddc25d3232a58fb526566665407582ec6 100644 (file)
@@ -311,6 +311,8 @@ sub do_cat_mail {
        my ($git, $blob, $sizeref) = @_;
        my $mime = eval {
                my $str = $git->cat_file($blob, $sizeref);
+               # fixup bugs from import:
+               $$str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s;
                Email::MIME->new($str);
        };
        $@ ? undef : $mime;