procmail
[Top] [All Lists]

Re: incorrect match

2004-11-16 01:18:08
At 22:23 2004-11-15 +0100, Travel Jadoo wrote:
I do get quite occasionally some incorrect matches. How could this be
possible?

A poor understanding of regexps.

Initially I had a .*SPAM* which I refined to .[SPAM* which is simply to
filter out and forward spam detected by spamassassin to me for
verification.

. * and [ (as well as various other symbols) are all special characters for regexp. If you expect to use them as literal symbols, you need to escape them.


* ^Subject:.[SPAM*

is a BROKEN expression. The dot means any one character. The open bracket means start a character class, and SPAM* are characters within that class. The regexp even manages to fail to CLOSE the character class.

If you're looking to match [SPAM] at the beginning of the subject line, then use a condition line like so:

* ^Subject:[    ]*\[SPAM\]

Note the brackets around SPAM are escaped, which sheds them of their special regexp meaning. The bracketed space before that is a space and tab.

If this is tagging inserted locally, you might check to see if there are other headers inserted (X-Spam-Status: or similar), instead of relying upon the subject line.

procmail: Match on "^Subject:.[SPAM*"
Subject: Photos from last Friday's cruise

Subject: followed by any one character (being a space in this case), followed by one of the characters in the class S, P, A, M, * (P in this case).

procmail: Match on "^Subject:.*SPAM*"
Subject: RE: Request for Spare Parts

This broken expression says match for Subject: followed by any number of any symbol (in this case " RE: Request for ", and then SPA, and optionally M (the * following M means ZERO or more). "Spa"re Parts meets this criteria.

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>