From: Eric Wong Date: Sat, 3 Oct 2015 10:18:07 +0000 (+0000) Subject: mda: support a 'filter=scrub' option for external lists X-Git-Tag: v1.0.0~797 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=9bc8cf2e9866393470cdb76a2af39d63f4246204 mda: support a 'filter=scrub' option for external lists 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. --- diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index 315d788b..0d73a867 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 1a9469ba..df8ca38c 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);