procmail
[Top] [All Lists]

Re: blocking certain attachments

2001-02-01 15:37:17
hi

On Thu, 1 Feb 2001, Takateru Ushiroda wrote:

I'd like to setup procmail to block file attachments with certain
extensions like .vbs, .shs, etc.  How would I do this.  I've checked out

here's a recipe, all credits go to Philip Guenther, I've just added
extensions I need to filter to his regexp.

# The regexp for matching whitespace in the embedded header field
# of a multipart message.  We have to handle wrapped lines.
ws = '[         ]*($[   ]+)*'

# The regexp for matching 'anything' inside an embedded header
# field of a multipart message.  That is, it matches anything
# except the newline (not followed by a whitespace character)
# that terminates the header field.
dotstar = '.*($[        ].*)*'

# A single double-quote.  For use in variable expanded regexps to
# avoid problems related to how procmail implements the variable
# expansion
dq = '"'

# Any condition that uses any of these variables in a its regexp
# must have the '$' special before the regexp to tell procmail to
# do variable expansion on the regexp.

# That matches if there exists a embedded Content-whatever header field
# whose value, ignoring legal whitespace, matches the regexp
#       .*name="filename"

ext = '\.(scr|vbs|shs|bat|com|exe|pif)'

:0 B
* $ ^Content-(Type|Disposition)*:${dotstar}name${ws}=${ws}${dq}.*${ext}${dq}
/dev/null

--
rgds,
serge

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail