-# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
+# Copyright (C) 2013-2015 all contributors <meta@public-inbox.org>
# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
#
# This only exposes one function: run
use constant NO_HTML => '*** We only accept plain-text email, no HTML ***';
# start with the same defaults as mailman
-our $BAD_EXT = qr/\.(?:exe|bat|cmd|com|pif|scr|vbs|cpl)\z/i;
-our $MIME_HTML = qr!\btext/html\b!i;
+our $BAD_EXT = qr/\.(exe|bat|cmd|com|pif|scr|vbs|cpl|zip)\s*\z/i;
+our $MIME_HTML = qr!\btext/x?html\b!i;
our $MIME_TEXT_ANY = qr!\btext/[a-z0-9\+\._-]+\b!i;
# this is highly opinionated delivery
# some extensions are just bad, reject them outright
my $fn = $part->filename;
if (defined($fn) && $fn =~ $BAD_EXT) {
+ $filter->reject("Bad file type: $1") if $filter;
$rejected++;
return;
}
# change the sender-specified type
if (recheck_type_ok($part)) {
push @keep, $part;
+ } elsif ($filter) {
+ $filter->reject('no attachments')
} else {
$rejected++;
}
push @keep, $part;
}
} else {
+ $filter->reject('no attachments') if $filter;
# reject everything else, including non-PGP signatures
$rejected++;
}
$mime->header_set('Content-Type', $part->content_type);
$mime->body_set($part->body_raw);
my $cte = $part->header('Content-Transfer-Encoding');
- if (defined($cte) && length($cte)) {
+ if (defined($cte) && $cte ne '') {
$mime->header_set('Content-Transfer-Encoding', $cte);
}
mark_changed($mime);