procmail
[Top] [All Lists]

Re: Matching literal dot in To

2015-06-14 09:52:37

On 2015-06-14 15:50, Erik Christiansen wrote:
On 14.06.15 08:30, Chuck Martin wrote:
On Sun, Jun 14, 2015 at 07:38:30PM +1000, Erik Christiansen wrote:

We need another tweak. This will be a great deal closer:

    * ^TO_.*\<[^.@ ]+\.[^.@ ]+@

That will not leap to the end of a mismatched address, but slide off it
in stages, because '\<' is only shorthand for `[^a-zA-Z0-9_]'. But we
needn't fuss over a lost microsecond here or there. It should do the job
now.

That will miss an address like abc(_dot_)def+ghi(_at_)example(_dot_)com.

That is not within the stated parameters. The stated goal is to detect
xxx.yyy@zzz But even if we assume that you have imagined a real need,
that does not mean that your "It may be necessary" is in any way
required.

Since '\<' is only shorthand for `[^a-zA-Z0-9_]', it is only necessary
to substitute the negative character class for the shorthand, and extend
it to [^a-zA-Z0-9_+].

Whether that is considered worth doing, we can but ask.

I didn't test it yet, but I think that .* is non-greedy outside of matches (and greedy within), so it should work fine also for plussed addresses.

So let's do a test:

$ cat testrc
#!/usr/bin/procmail -m

LOGABSTRACT=no
VERBOSE=no

n="
"
LOG="${n}Starting ...$n"

:0
* ^TO_.*\<[^.@ ]+\.[^.@ ]+@
{
  LOG="FOUND$n"
}

:0
* ^TO_.*\<\/[^.@ ]+\.[^.@ ]+@[^, ]+
{
  LOG="MATCH: $MATCH$n"
}

LOG="Done.$n$n"

- - - - - -

$ chmod -vv u+x testrc
testrc: 0100644 [-rw-r--r-- ] -> 0100744 [-rwxr--r-- ]

- - - - - -

$ echo "To: abc(_at_)def(_dot_)ghi foo(_dot_)bar+baz(_at_)test(_dot_)com 
rst(_at_)uvw(_dot_)xyz" | ./testrc

Starting ...
FOUND
MATCH: foo(_dot_)bar+baz(_at_)test(_dot_)com
Done.

--
Greetings, Ruud
____________________________________________________________
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>