procmail
[Top] [All Lists]

Re: Can't MATCH?

2002-12-22 08:13:44
Paul Chvostek <paul(_at_)it(_dot_)ca> wrote:

I've got some recipes which look for list names.  The following is a bit
ugly because I keep trying to add things to strip off stuff that simply
does not want to be stripped.  At this point, the recipe has grown to:

"Ugly" is right.  :)  The first thing I'd do is simplify it substantially,
so a normal human can follow it.  :)

 :0
 * ^\/(Mailing-List:.+(imp|horde|twig)-help@|\
   Delivered-To:(_dot_)+(_at_)lists\(_dot_)securityfocus\(_dot_)com|\
   
Sender:.+((owner|admin|bounce)-[a-z0-9_-]+|[a-z0-9_-]+-(admin|owner|bounce)@[a-z0-9\.-]+))
 * MATCH ?? ^[^:]+:[     ]+([a-z0-9 ]+<)?((owner|admin|bounce)-)?\/.*
 * MATCH ?? ^[^a-z]*\/[^(_at_)]+
 * MATCH ?? ^(owner-)?\/.+

I keep data for such things in a seperate INCLUDERC, where I assign variables.

 LISTPREFIX  = (admin|bounce|owner)
 SUBSTRING   =  [a-zA-Z0-9_-]+

 MAILINGLIST = (imp|horde|twig)-help
 DELIVTOLIST = lists.securityfocus.com
 SENDERLIST  = $(LISTPREFIX-)?$SUBSTRING(-$LISTPREFIX(_at_)$SUBSTRING)?

 :0
 * $ ^\/$MAILINGLIST|$\DELIVTOLIST|$SENDERLIST
 * $ MATCH ?? $LISTPREFIX-\/.+
 *   MATCH ?? ()\/[^(_at_)]+
 { LISTNAME = $MATCH }


Well, try that.  Most probably needs further work, as it's completely untested.

When you say something like

  * MATCH ?? ^[^a-z]*\/[^(_at_)]+

The "not-" charset can be zero-length, so I don't see a point in
having it there at all.  Hence my simplification to

 *   MATCH ?? ()\/[^(_at_)]+

For a similar reason, your logs show:

 procmail: Matched "owner-srh"
 procmail: Match on "^(owner-)?\/.+"
 procmail: Assigning "LISTNAME=owner-srh"

It's because of your "one-or-none" question mark.  Procmail chooses the easiest,
which is "none."

In any case, start with one simple statement that works, then build on it
piecemeal until you have the whole thing.

-- 
dman


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

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