X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FFilter%2FBase.pm;h=052cd3328aa66a470a9ddb19845edca3a1dcc4ce;hb=9bd675d33ad1e49bd2ebe12a1d216216e61380de;hp=0991e8748820e11b8a112728fbca2b6083c925c2;hpb=61f05bf5869c3f471a16926b1a837ab0d95fb095;p=public-inbox.git
diff --git a/lib/PublicInbox/Filter/Base.pm b/lib/PublicInbox/Filter/Base.pm
index 0991e874..052cd332 100644
--- a/lib/PublicInbox/Filter/Base.pm
+++ b/lib/PublicInbox/Filter/Base.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2016 all contributors
+# Copyright (C) 2016-2019 all contributors
# License: AGPL-3.0+
#
# base class for creating per-list or per-project filters
@@ -8,11 +8,14 @@ use warnings;
use PublicInbox::MsgIter;
use constant MAX_MID_SIZE => 244; # max term size - 1 in Xapian
-my $NO_HTML = '*** We only accept plain-text mail, no HTML ***';
+sub No ($) { "*** We only accept plain-text mail, No $_[0] ***" }
+
our %DEFAULTS = (
- reject_suffix => [ qw(exe bat cmd com pif scr vbs cpl zip) ],
- reject_type => [ "text/html:$NO_HTML", "text/xhtml:$NO_HTML",
- 'application/vnd.ms-*:No proprietary data formats' ],
+ reject_suffix => [ qw(exe bat cmd com pif scr vbs cpl zip swf swfl) ],
+ reject_type => [ 'text/html:'.No('HTML'), 'text/xhtml:'.No('HTML'),
+ 'application/vnd.*:'.No('vendor-specific formats'),
+ 'image/*:'.No('images'), 'video/*:'.No('video'),
+ 'audio/*:'.No('audio') ],
);
our $INVALID_FN = qr/\0/;
@@ -62,6 +65,14 @@ sub reject ($$) {
sub err ($) { $_[0]->{err} }
+# by default, scrub is a no-op, see PublicInbox::Filter::Vger::scrub
+# for an example of the override. The $for_remove arg is set to
+# disable altid setting for spam removal.
+sub scrub {
+ my ($self, $mime, $for_remove) = @_;
+ $self->ACCEPT($mime);
+}
+
# for MDA
sub delivery {
my ($self, $mime) = @_;
@@ -94,7 +105,7 @@ sub delivery {
push @r, 'Rejected suffixes(s): '.join(', ', sort keys %sfx);
}
- @r ? $self->reject(join("\n", @r)) : $self->ACCEPT;
+ @r ? $self->reject(join("\n", @r)) : $self->scrub($mime);
}
1;