X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FFilter%2FBase.pm;h=d54570fd9efb8872d7eb9cf2368046720e7c86ec;hb=95bdac7f09c69036efed537a4d03d5bdd2ae4eb6;hp=37f1ee7e59ea76d0211f82c42206a6268b792842;hpb=160a6d5672fef64c174c8d79c07851eaadf6d0e6;p=public-inbox.git diff --git a/lib/PublicInbox/Filter/Base.pm b/lib/PublicInbox/Filter/Base.pm index 37f1ee7e..d54570fd 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-2020 all contributors # License: AGPL-3.0+ # # base class for creating per-list or per-project filters @@ -6,13 +6,17 @@ package PublicInbox::Filter::Base; use strict; use warnings; use PublicInbox::MsgIter; -use constant MAX_MID_SIZE => 244; # max term size - 1 in Xapian +use parent qw(Exporter); +our @EXPORT_OK = qw(REJECT); # we may export IGNORE if/when needed + +sub No ($) { "*** We only accept plain-text mail, No $_[0] ***" } -my $NO_HTML = '*** We only accept plain-text mail, no HTML ***'; 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/; @@ -63,9 +67,10 @@ sub reject ($$) { sub err ($) { $_[0]->{err} } # by default, scrub is a no-op, see PublicInbox::Filter::Vger::scrub -# for an example of the override +# for an example of the override. The $for_remove arg is set to +# disable altid setting for spam removal. sub scrub { - my ($self, $mime) = @_; + my ($self, $mime, $for_remove) = @_; $self->ACCEPT($mime); }