procmail
[Top] [All Lists]

Re: bug in ^TO_ macro: character '+' *is* allowed in emails

2004-11-26 07:22:41
On Fri, Nov 26, 2004 at 05:17:42AM -0800, Tristan Savatier wrote:

[Ruud wrote (but the attribution was snipped):]
[Tristan wrote (but the attribution was snipped):]

^TO_hugs(_at_)foo\(_dot_)com[^-a-zA-Z0-9(_dot_)]?

A regex ending in an optional part, is better without that optional
part.

I have no idea what you mean.

This regexp means that if anything follows \.com, it would not be a
character allowed in a domain name.

this would exclude hugs(_at_)foo(_dot_)com(_dot_)br and 
hugs(_at_)foo(_dot_)comitee(_dot_)org for example

I understood that you meant for it to mean that; and Ruud did, too,
unless I am very mistaken.  But that's not in fact what it means.

Procmail's regex parsing (absent the match token, i.e., in the normal
case) is not of the greedy variety, but rather its opposite: sparse or
spare.  So

   string

matches exactly the same thing as

   string.*

and also the same thing as

   string[^.]?

In all three cases, procmail gets to the end of a successful match
of "string" and asks itself, "is there anything else I need to match
to satisfy the minimum requirements of this regex?"  And, since in
both the case of ".*" ("zero or more chars") and the case of "[^.]*"
("zero or more of a class of things not any regular char, e.g., a
newline"), the answer is a strident "No!"  Nothing more is needed;
the match has been fulfilled.  We don't need to see if there are
zero or more of anything, because zero is enough to satisfy the match.

This is trivial to test:

---------------------------------------------------------------------
  FOO = "hugs(_at_)foo(_dot_)command(_dot_)central(_dot_)co(_dot_)uk"

  :0
  * FOO ?? ^^hugs(_at_)foo\(_dot_)com[^-a-zA-Z0-9(_dot_)]?
  { LOG = "$NL We are here because we matched! $NL" }
---------------------------------------------------------------------
(Assumes "$NL" was set previously to newline.)

Here's the result:

 procmail: Assigning 
"FOO=hugs(_at_)foo(_dot_)command(_dot_)central(_dot_)co(_dot_)uk"
 procmail: Match on "^^hugs(_at_)foo\(_dot_)com[^-a-zA-Z0-9(_dot_)]?"
 procmail: Assigning "LOG=
  We are here because we matched! 
 "

  We are here because we matched! 


-- 
dman

____________________________________________________________
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