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
}
}