3 messages in net.sourceforge.lists.courier-maildrop[maildropl] matching content-type - p...
FromSent OnAttachments
Gregor LawatscheckSep 11, 2003 8:26 am 
Gregor LawatscheckSep 23, 2003 12:41 pm 
Gregor LawatscheckSep 24, 2003 5:05 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[maildropl] matching content-type - possible regex bug?Actions...
From:Gregor Lawatscheck (gp@mpex.net)
Date:Sep 11, 2003 8:26:24 am
List:net.sourceforge.lists.courier-maildrop

Hi,

I have a simple question about regular expressions in maildrop 1.6.0: Consider the following (simplified):

if (/^Content-Type: multipart/:h) { BLOCKEDTYPES="(pif|scr|shs|vbs|vbe|eml|com|bat|hta|wsf|wsh|shb)" if (/^Content-Type:[:space:].*name=.*\.$BLOCKEDTYPES(\")?$/:b) echo "BAD TYPE" }

Why would the second if (/^Content-Type:[...]) be true and $MATCH be "Content-Type: multipart" (from the first if) when there is a file with a different extension than listed?

Trying a work around:

if (/^Content-Type: multipart/:h) { $MATCH="" BLOCKEDTYPES="(pif|scr|shs|vbs|vbe|eml|com|bat|hta|wsf|wsh|shb)" if (/^Content-Type:[:space:].*name=.*\.$BLOCKEDTYPES(\")?$/:b) echo "BAD TYPE" }

Here the second if (/^Content-Type:[...]) is still true but $MATCH is empty as set before the second if.

Shouldn't the second if be false with a different filetype? Why should $MATCH remain empty but the if hold true? What do I oversee?

My workaround at the moment is to check with a third if ($MATCH =~ /name/) to see if it really matches.

My full check for bad attachment types with the work around below (might be useful for some people). If anyone sees a better (faster) way of doing the attachment checking I'd appreciate it:

if (/^Content-Type: multipart/:h) { BLOCKEDTYPES="(pif|scr|shs|vbs|vbe|eml|com|bat|hta|wsf|wsh|shb)" if (/^Content-Type:[:space:].*;[:space:]name=.*\.$BLOCKEDTYPES(\")?$/:b || /^\tname=.*\.$BLOCKEDTYPES(\")?$/:b) { NAME=$MATCH if ($MATCH =~ /name/) {

echo "BAD TYPE" NAME=escape($NAME) echo $NAME # I'm generating a bad extension report and put it in the users Virus Maildir # on a vpopmail setup # ymmv xfilter "/var/vpopmail/bin/badextreport" to "$VHOME/Maildir/.Virus"

EXITCODE=99 exit } } }