3 messages in net.sourceforge.lists.courier-maildropRe: [maildropl] matching content-type...
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:Re: [maildropl] matching content-type - possible regex bug?Actions...
From:Gregor Lawatscheck (gp@mpex.net)
Date:Sep 23, 2003 12:41:59 pm
List:net.sourceforge.lists.courier-maildrop

At 17:10 11/09/2003, you wrote:

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?

OK let me try answer my own question. Not sure whether this is a regex bug - it's more likely my regex was a little too greedy. Using .+ instead of .* works fine somehow.

Just strange $MATCH isn't set at all with .* -- afaik the only difference between .* and .+ is that .* also matches 0 occurrences - which doesn't matter in this case: Content-Type: application/octet-stream; name="blah.pif"

This is my refined bad filetype check which works so far:

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) { echo "BAD TYPE" NAME=escape($MATCH) echo $MATCH cc "/var/vpopmail/domains/mpex.net/testgpel/Maildir" xfilter "/var/vpopmail/bin/badextreport" to "$VHOME/Maildir/.Virus"

EXITCODE=99 exit } }