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
_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID. You may ignore it.
Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list [email protected]
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang