From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 264651FAE5 for ; Thu, 22 Mar 2018 09:40:16 +0000 (UTC) From: "Eric Wong (Contractor, The Linux Foundation)" To: meta@public-inbox.org Subject: [PATCH 03/13] import: discard all the same headers as MDA Date: Thu, 22 Mar 2018 09:40:05 +0000 Message-Id: <20180322094015.14422-4-e@80x24.org> In-Reply-To: <20180322094015.14422-1-e@80x24.org> References: <20180322094015.14422-1-e@80x24.org> List-Id: Reduce the places where we have duplicate logic for discarding unwanted headers. --- lib/PublicInbox/Import.pm | 2 ++ lib/PublicInbox/MDA.pm | 2 -- lib/PublicInbox/WatchMaildir.pm | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm index fc740fa..e50f115 100644 --- a/lib/PublicInbox/Import.pm +++ b/lib/PublicInbox/Import.pm @@ -13,6 +13,7 @@ use PublicInbox::MID qw(mids mid_mime mid2path); use PublicInbox::Address; use PublicInbox::MsgTime qw(msg_timestamp); use PublicInbox::ContentId qw(content_digest); +use PublicInbox::MDA; sub new { my ($class, $git, $name, $email, $ibx) = @_; @@ -319,6 +320,7 @@ sub add { # kill potentially confusing/misleading headers $mime->header_set($_) for qw(bytes lines content-length status); + $mime->header_set($_) for @PublicInbox::MDA::BAD_HEADERS; # spam check: if ($check_cb) { diff --git a/lib/PublicInbox/MDA.pm b/lib/PublicInbox/MDA.pm index d5af8f9..637404e 100644 --- a/lib/PublicInbox/MDA.pm +++ b/lib/PublicInbox/MDA.pm @@ -81,8 +81,6 @@ sub set_list_headers { $pa =~ tr/@/./; # RFC2919 $simple->header_set("List-Id", "<$pa>"); } - - $simple->header_set($_) foreach @BAD_HEADERS; } 1; diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm index b165a60..d3ca2a1 100644 --- a/lib/PublicInbox/WatchMaildir.pm +++ b/lib/PublicInbox/WatchMaildir.pm @@ -159,7 +159,6 @@ sub _try_path { } my $im = _importer_for($self, $inbox); my $mime = _path_to_mime($path) or return; - $mime->header_set($_) foreach @PublicInbox::MDA::BAD_HEADERS; my $wm = $inbox->{-watchheader}; if ($wm) { my $v = $mime->header_obj->header_raw($wm->[0]); -- EW