procmail
[Top] [All Lists]

Re: Troubles with $MATCH

2003-12-09 20:24:33
"Ruud H.G. van Tol" <rvtol(_at_)isolution(_dot_)nl> wrote:
Charles Gregory <cgregory(_at_)hwcn(_dot_)org> wrote:

* ^(To|Cc):(_dot_)*sbirl\+[^(_at_)]+@concept\.
* ^(To|Cc):.*sbirl\+\/[^(_at_)]+
.email_alias_$MATCH

  :0:
  * ^(To|Cc):.*\<sbirl\+\/[a-z]+(_at_)concept\(_dot_)
  * MATCH ?? ^^\/[^(_at_)]+
  .email_alias_$MATCH

Good.  With this, it's no longer necessary, but still good practice to
protect variable substitutions in action lines with double quotes.  As
has been alluded to but not spelled out, the leading space in front of
"amazon" split the matching action line into two parts ".email_alias_"
and "amazon(_at_)concept(_dot_)".  Here's how that space got in there.  Birl 
had:

    * ^(To|Cc):.*\/[^(_at_)]+@concept\.

Given the input line "To: 
amazon(_at_)concept(_dot_)ocis(_dot_)temple(_dot_)edu", "[^(_at_)]", not
".*", matched the space.  That's because "\/" captures a maximal match
to the right, and everything to the left is a minimal match.  So if no
occurrences is possible on the left, that's all that will match there.
A standard cure for this is to anchor the ".*" with a "\<", as ".*\<".
It so happens that the handy "^TO_" macro is great for this situation.

Another problem is that the catch-all comes before the specific parse.
Anything that could conceivably match:

    * ^(To|Cc):.*sbirl\+\/[^+]+(_at_)concept\(_dot_)

Will already have gotten intercepted by the preceding catch-all.  This
is probably just something that got done while Birl was experimenting.
Here's one possible coding, that takes into account all the foregoing:

  IDENT = "[a-z0-9][a-z0-9._=+-]*"
  PLUS  = "sbirl+"
  SITE  = "concept.temple.edu"
  GO    = "9876543210"

  :0
  * $ $GO^0 ^TO_$\PLUS\/$IDENT(_at_)$\SITE
  * $ $GO^0       ^TO_\/$IDENT(_at_)$\SITE
  {
    :0:
    * MATCH ??        ^^$IDENT
    ".email_alias_$MATCH"
  }

I've added a new feature to my own procmail, so I can do it like this:

  :0:
  * $ $GO^0 ^TO_$\PLUS\/$IDENT\/@$\SITE
  * $ $GO^0       ^TO_\/$IDENT\/@$\SITE
  ".email_alias_$MATCH"

The second match delimiter specifies that the latter part be stripped.

Mike


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