package PublicInbox::WatchMaildir;
use strict;
use warnings;
-use PublicInbox::MIME;
+use PublicInbox::Eml;
use PublicInbox::InboxWritable;
use File::Temp 0.19 (); # 0.19 for ->newdir
use PublicInbox::Filter::Base qw(REJECT);
if (my $whs = $ibx->{watchheader}) {
for (@$whs) {
my ($k, $v) = split(/:/, $_, 2);
+ # XXX should this be case-insensitive?
+ # Or, mutt-style, case-sensitive iff
+ # a capital letter exists?
push @$watch_hdrs, [ $k, qr/\Q$v\E/ ];
}
}
if (my $list_ids = $ibx->{listid}) {
for (@$list_ids) {
- my $re = qr/<[ \t]*\Q$_\E[ \t]*>/;
+ # RFC2919 section 6 stipulates
+ # "case insensitive equality"
+ my $re = qr/<[ \t]*\Q$_\E[ \t]*>/i;
push @$watch_hdrs, ['List-Id', $re ];
}
}
my $ok;
my $hdr = $mime->header_obj;
for my $wh (@$watch_hdrs) {
- my $v = $hdr->header_raw($wh->[0]);
- next unless defined($v) && $v =~ $wh->[1];
- $ok = 1;
- last;
+ my @v = $hdr->header_raw($wh->[0]);
+ $ok = grep(/$wh->[1]/, @v) and last;
}
next unless $ok;
}
my ($mime) = @_;
my $tmp = '';
if ($sc->spamcheck($mime, \$tmp)) {
- return PublicInbox::MIME->new(\$tmp);
+ return PublicInbox::Eml->new(\$tmp);
}
warn $mime->header('Message-ID')." failed spam check\n";
undef;