* [PATCH] import: normalize body by stripping trailing newlines
@ 2016-05-12 9:52 7% Eric Wong
0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2016-05-12 9:52 UTC (permalink / raw)
To: meta
Mbox formatters may add extra newlines at the end of the
message, and that's not relevant for comparing messages
for deletion.
---
lib/PublicInbox/Import.pm | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 5a3c585..1f52a0c 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -65,6 +65,13 @@ sub now2822 () {
$day, $t[3], $mon, $t[5] + 1900, $t[2], $t[1], $t[0]);
}
+sub norm_body ($) {
+ my ($mime) = @_;
+ my $b = $mime->body_raw;
+ $b =~ s/(\r?\n)+\z//s;
+ $b
+}
+
# returns undef on non-existent
# ('MISMATCH', msg) on mismatch
# (:MARK, msg) on success
@@ -106,7 +113,7 @@ sub remove {
die "bad read on final byte: <$lf>" if $lf ne "\n";
my $cur = Email::MIME->new($buf);
if ($cur->header('Subject') ne $mime->header('Subject') ||
- $cur->body ne $mime->body) {
+ norm_body($cur) ne norm_body($mime)) {
return ('MISMATCH', $cur);
}
^ permalink raw reply related [relevance 7%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-05-12 9:52 7% [PATCH] import: normalize body by stripping trailing newlines 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).