diff options
author | Eric Wong <normalperson@yhbt.net> | 2014-02-11 00:36:06 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2014-02-11 00:36:06 +0000 |
commit | 858f0a2960123d6d2cbced1bb18e4e5e524df21e (patch) | |
tree | fae844af890e158f116f6369935cdecf4812fe41 /lib | |
parent | b5b6e0f45c5ee171d71b549146432a68d6707531 (diff) | |
download | public-inbox-858f0a2960123d6d2cbced1bb18e4e5e524df21e.tar.gz |
move pre-spamc checks to PublicInbox->precheck
We may add more checks before we go to spamc.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox.pm | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/PublicInbox.pm b/lib/PublicInbox.pm index b51c000f..899027be 100644 --- a/lib/PublicInbox.pm +++ b/lib/PublicInbox.pm @@ -4,6 +4,7 @@ package PublicInbox; use strict; use warnings; use Email::Address; +use constant MAX_SIZE => 1024 * 500; # same as spamc default # drop plus addressing for matching sub __drop_plus { @@ -13,8 +14,15 @@ sub __drop_plus { } # do not allow Bcc, only Cc and To if ORIGINAL_RECIPIENT (postfix) env is set -sub recipient_specified { +sub precheck { my ($klass, $filter) = @_; + return 0 unless defined($filter->from); + return 0 if length($filter->simple->as_string) > MAX_SIZE; + recipient_specified($filter); +} + +sub recipient_specified { + my ($filter) = @_; my $or = $ENV{ORIGINAL_RECIPIENT}; defined($or) or return 1; # for imports my @or = Email::Address->parse($or); |