From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable version=3.3.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E1B01633835 for ; Thu, 12 May 2016 09:52:05 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] import: normalize body by stripping trailing newlines Date: Thu, 12 May 2016 09:52:03 +0000 Message-Id: <20160512095205.6139-1-e@80x24.org> List-Id: 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); }