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=-2.8 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, T_RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 94D3363385A for ; Sat, 3 Oct 2015 11:14:13 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/4] mda: support a 'filter=scrub' option for external lists Date: Sat, 3 Oct 2015 11:14:11 +0000 Message-Id: <20151003111411.1003-5-e@80x24.org> In-Reply-To: <20151003111411.1003-1-e@80x24.org> References: <20151003111411.1003-1-e@80x24.org> List-Id: For list where we are not the primary archival entry point, defaulting to filter=scrub makes sense since their list conventions may be more tolerant of HTML and other crap than we are. --- lib/PublicInbox/Config.pm | 2 +- public-inbox-mda | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index 315d788..0d73a86 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -61,7 +61,7 @@ sub lookup { defined $pfx or return; my %rv; - foreach my $k (qw(mainrepo address)) { + foreach my $k (qw(mainrepo address filter)) { my $v = $self->{"$pfx.$k"}; $rv{$k} = $v if defined $v; } diff --git a/public-inbox-mda b/public-inbox-mda index 1a9469b..df8ca38 100755 --- a/public-inbox-mda +++ b/public-inbox-mda @@ -38,7 +38,18 @@ if (PublicInbox::MDA->precheck($filter, $dst->{address}) && $filtered = undef; $filter->simple($msg); - if (PublicInbox::Filter->run($msg, $filter)) { + my $filter_arg; + my $fcfg = $dst->{filter}; + if (!defined $fcfg || $filter eq 'reject') { + $filter_arg = $filter; + } elsif ($fcfg eq 'scrub') { + $filter_arg = undef; # the default for legacy versions + } else { + warn "publicinbox.$dst->{listname}.filter=$fcfg invalid\n"; + warn "must be either 'scrub' or 'reject' (the default)\n"; + } + + if (PublicInbox::Filter->run($msg, $filter_arg)) { # run spamc again on the HTML-free message if (do_spamc($msg, \$filtered)) { $msg = Email::MIME->new(\$filtered); -- EW