* Re: Extra newline when retrieving messages
@ 2020-12-10 20:55 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-12-10 20:55 UTC (permalink / raw)
To: Konstantin Ryabitsev; +Cc: meta
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 {
^ permalink raw reply related [relevance 7%]
* [PATCH] mbox: unconditionally add trailing newline
@ 2016-04-11 5:07 6% Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2016-04-11 5:07 UTC (permalink / raw)
To: meta
This may be necessary for compatibility with non-mboxrd aware
parsers which expect "\nFrom " for everything but the first
record.
---
lib/PublicInbox/Mbox.pm | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index 0d67981..9f20580 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -67,9 +67,7 @@ sub emit_msg {
# ref: http://www.qmail.org/man/man5/mbox.html
$buf =~ s/^(>*From )/>$1/gm;
- $buf .= "\n" unless $buf =~ /\n\z/s;
-
- $fh->write($buf);
+ $fh->write($buf .= "\n");
}
sub emit_mbox {
--
EW
^ permalink raw reply related [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-04-11 5:07 6% [PATCH] mbox: unconditionally add trailing newline Eric Wong
2020-12-10 20:21 Extra newline when retrieving messages Konstantin Ryabitsev
2020-12-10 20:55 7% ` Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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).