]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/MDA.pm
Merge branch 'thread-view-skel'
[public-inbox.git] / lib / PublicInbox / MDA.pm
index e1207b56e3aad365f9989c73bd72fd38bc7e3d12..0f583e65a6a2fb3473f4873fe766d42f523a0eb0 100644 (file)
@@ -6,7 +6,6 @@ package PublicInbox::MDA;
 use strict;
 use warnings;
 use Email::Simple;
-use Email::Address;
 use Date::Parse qw(strptime);
 use constant MAX_SIZE => 1024 * 500; # same as spamc default, should be tunable
 use constant MAX_MID_SIZE => 244; # max term size - 1 in Xapian
@@ -33,18 +32,17 @@ sub __drop_plus {
 
 # do not allow Bcc, only Cc and To if recipient is set
 sub precheck {
-       my ($klass, $filter, $address) = @_;
-       my Email::Simple $simple = $filter->simple;
+       my ($klass, $simple, $address) = @_;
        my @mid = $simple->header('Message-ID');
        return 0 if scalar(@mid) != 1;
        my $mid = $mid[0];
        return 0 if (length($mid) > MAX_MID_SIZE);
        return 0 unless usable_str(length('<m@h>'), $mid) && $mid =~ /\@/;
-       return 0 unless usable_str(length('u@h'), $filter->from);
+       return 0 unless usable_str(length('u@h'), $simple->header("From"));
        return 0 unless usable_str(length(':o'), $simple->header("Subject"));
        return 0 unless usable_date($simple->header("Date"));
        return 0 if length($simple->as_string) > MAX_SIZE;
-       alias_specified($filter, $address);
+       alias_specified($simple, $address);
 }
 
 sub usable_str {
@@ -58,17 +56,17 @@ sub usable_date {
 }
 
 sub alias_specified {
-       my ($filter, $address) = @_;
+       my ($simple, $address) = @_;
 
        my @address = ref($address) eq 'ARRAY' ? @$address : ($address);
        my %ok = map {
-               my @recip = Email::Address->parse($_);
-               lc(__drop_plus($recip[0]->address)) => 1;
+               lc(__drop_plus($_)) => 1;
        } @address;
 
-       foreach my $line ($filter->cc, $filter->to) {
-               foreach my $addr (Email::Address->parse($line)) {
-                       if ($ok{lc(__drop_plus($addr->address))}) {
+       foreach my $line ($simple->header('Cc'), $simple->header('To')) {
+               my @addrs = ($line =~ /([^<\s]+\@[^>\s]+)/g);
+               foreach my $addr (@addrs) {
+                       if ($ok{lc(__drop_plus($addr))}) {
                                return 1;
                        }
                }