unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/1] inbox: ensure we do not show leading "From " lines
Date: Sun, 26 Jun 2016 23:39:07 +0000	[thread overview]
Message-ID: <20160626233907.GA5728@dcvr.yhbt.net> (raw)
In-Reply-To: <20160626233131.7531-1-e@80x24.org>

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     | 4 +++-
 lib/PublicInbox/SearchIdx.pm | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index 34191fc..87c2c9f 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -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 ($$;$) {
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index 58eccc1..c2bf9a2 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -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;
-- 
EW

  reply	other threads:[~2016-06-26 23:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-26 23:31 [PATCH] mda: drop leading "From " lines again Eric Wong
2016-06-26 23:39 ` Eric Wong [this message]
2016-06-26 23:42   ` [PATCH 3/1] inbox: avoid trying s// on undef Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160626233907.GA5728@dcvr.yhbt.net \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).