unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Cc: meta@public-inbox.org
Subject: Re: Extra newline when retrieving messages
Date: Thu, 10 Dec 2020 20:55:40 +0000	[thread overview]
Message-ID: <20201210205540.GA10371@dcvr> (raw)
In-Reply-To: <20201210202145.7agtcmrtl5jec42d@chatter.i7.local>

Konstantin Ryabitsev <konstantin@linuxfoundation.org> wrote:
> Hello:
> 
> While investigating why some of the messages retrieved via 
> lore.kernel.org were failing DKIM checks, I realized that 
> public-inbox-httpd appends an extra newline to message bodies. This 
> newline isn't present in git backends, just in messages retrieved via 
> (at least) public-inbox-httpd. 

It looks like a regression from commit dbdc7a42dd885523 (2016-04-11);
which now doesn't make sense, though very little is making sense
to me nowadays :<

The following should undo it, unless somebody DKIM signed a
message which lacked any trailing "\n" at all.  I'm not sure
if it's possible to get a message lacking a trailing "\n"
through any MTA, though.

So I think the following should fix it, but I'm having even more
trouble than usual trusting anything I do:

---------8<----------
Subject: [PATCH] mbox: only add a trailing newline if one does not exist

In retrospect, commit dbdc7a42dd885523 from 2016-04-11
did not make sense since the CR would've been added before
the "From " line anyways.

Fixes: dbdc7a42dd885523 ("mbox: unconditionally add trailing newline")
Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Link: https://public-inbox.org/meta/20201210202145.7agtcmrtl5jec42d@chatter.i7.local/
---
 lib/PublicInbox/Mbox.pm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index c88350c9..1895d7e6 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -133,7 +133,11 @@ sub msg_body ($) {
 	# https://www.loc.gov/preservation/digital/formats/fdd/fdd000385.shtml
 	# https://web.archive.org/http://www.qmail.org/man/man5/mbox.html
 	$$bdy =~ s/^(>*From )/>$1/gm;
-	$$bdy .= "\n";
+
+	# some messages lack a trailing newline, there needs to be one
+	# before the "From " line for the next message
+	$$bdy .= "\n" if substr($$bdy, -1, 1) ne "\n";
+	$$bdy;
 }
 
 sub thread_cb {

  reply	other threads:[~2020-12-10 20:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-10 20:21 Extra newline when retrieving messages Konstantin Ryabitsev
2020-12-10 20:55 ` Eric Wong [this message]
2020-12-10 21:43   ` Konstantin Ryabitsev
2020-12-10 22:29     ` Konstantin Ryabitsev
2020-12-10 22:38     ` Eric Wong
2020-12-10 22:41       ` Konstantin Ryabitsev

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=20201210205540.GA10371@dcvr \
    --to=e@80x24.org \
    --cc=konstantin@linuxfoundation.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).