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