[Mimedefang] Improvement of re_match
Steffen Kaiser
skmimedefang at smail.inf.fh-bonn-rhein-sieg.de
Thu Jan 5 10:30:13 EST 2006
Hello,
I would like to suggest an improvement of re_match in order to get to know
_why_ the filename is bad, the following function is modelled after
re_match:
===
sub ska_match ($$) {
my($entity, $regexp) = @_;
my($head) = $entity->head;
my($guess) = $head->mime_attr("Content-Disposition.filename");
if(defined($guess)) {
$guess = decode_mimewords($guess);
if(my @result = decode_mimewords($guess) =~ /$regexp/i) {
return @result; # return the match
}
}
$guess = $head->mime_attr("Content-Type.name");
if (defined($guess)) {
$guess = decode_mimewords($guess);
if(my @result = decode_mimewords($guess) =~ /$regexp/i) {
return @result; # return the match
}
}
$guess = $head->mime_attr("Content-Description");
if (defined($guess)) {
$guess = decode_mimewords($guess);
if(my @result = decode_mimewords($guess) =~ /$regexp/i) {
return @result; # return the match
}
}
return (); # No match found
}
====
if(re_match(...)) {
}
works as usual; but you get to know, what match (usually the $bad_exts),
because the n'th item in the array corresponds to the (n+1)'th '(' block
of the regex (aka $1, $2 a.s.o).
E.g.:
if(my @bad = re_match(...)) {
return action_bounce('Attachments of type ' . $bad[0] . ' are
blocked');
}
Bye,
--
Steffen Kaiser
More information about the MIMEDefang
mailing list