procmail
[Top] [All Lists]

Re: Matching a host

1997-05-15 07:59:00
On Thu, 15 May 1997 07:51:08 -0400 (EDT),
Brock Rozen <brozen(_at_)webdreams(_dot_)com> wrote:
I use the following to match anything within a domain name. Is this a good
way of doing it or does the code have problems?
WDHOST=(@|%|!)?(((.*)?\.)?(webdreams\.com))
                     ^^
This wildcard will match anything, which may or may not be a problem. 
I often use a -- radically less general -- simpler regular expression,
which is some variation of

    @([^        ,]*\.)?domain\.com

To: webmaster(_at_)yahoo(_dot_)com, 
nobody(_at_)nowhere(_dot_)webdreams(_dot_)com or even
To: webmaster_joe, 
lukewarm(_dot_)webdreams(_dot_)coming(_dot_)from(_at_)frobozz(_dot_)net would
match on your regular expression. While these are rather wretched
examples, you always seem to run into someone who is just wretched
enough ...

I also get the feeling your intent is to match either a bare webmaster
(for local mail) or one with your domain, including subdomains, tacked
on. Is this correct? Then you might try something like 

    * ^TOwebmaster((@[^  ,]*\.)?webdreams\.com)?([,     ].*)?$

but there seems always to be yet another case that slips through the
cracks -- RFC822 is hairy. (In fact, you can use nested comments to
produce addresses which simply cannot be matched reliably with regular
expressions. Eli the Bearded has a FAQ which mentions the problems in
passing -- it has some good examples of what you might run into.
<http://www.netusa.net/~eli/faqs/addressing.html>)

For practical purposes, though, the above should be enough unless you
run into someone who is putting some real effort into breaking your
systems. (I wish I could say running Windows NT might be construed as
such :-)

The expression [        ,] is my personal idea of what might be used
to separate several addresses in a header field. It is not the same as
e.g. what the ^TO_ macro uses (which is [^-a-zA-Z0-9_.]) but I'm not
sure which I'd recommend. (Trust Stephen's judgment, not mine :-)

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

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