[Mimedefang] Dropping Files

Paul Heinlein heinlein at cse.ogi.edu
Mon Oct 27 13:37:40 EST 2003


On Mon, 27 Oct 2003, schmaus wrote:

> I had this snippet of code in my filter sub routine.  And while it
> matches on the 3 attachments listed in $drop_exts, it also drops
> other files, like doc and xls.  Can anyone explain why this would be
> happening?

It happens because you aren't anchoring your regex to the end of the
string.

So you can either use re_match_ext() in place of re_match, or you can
make your regex somewhat more explicit:

  $drop_exts = qr/\.(?:pif|scr|bat)(?:\.|$)/;

> $drop_exts = '(pif|scr|bat)';
> if (re_match($entity, $drop_exts)) {
>      md_graphdefang_log("VIRUS: dropping file $fname from
> $RelayAddr");
>      return action_discard();
> }

--Paul Heinlein <heinlein at cse.ogi.edu>



More information about the MIMEDefang mailing list