procmail
[Top] [All Lists]

Re: RFC-consistent regexp to match name@(subdomain.)*foo.bar

1997-02-20 16:10:09
I've learned a lot from the great responses.  One thing I learned is
that my inquiry was poorly worded.

Philip Guenther uses the phrase "minimal form" address, and in fact I
guess that is what I wanted a regexp for.

I want to provide an automatic reply service, recognizing a subject
like:

    Subject: send-weather-report name(_at_)subdomain(_dot_)foo(_dot_)bar

with recipe & action like

    * ^Subject: send-weather-report \/[a-z].*@([a-z][a-z0-9_-]*\.)*foo\.bar$
    | cat > /dev/null; mail "$MATCH" < $WEATHER

The regexp I want must be in any auto-subscribe mailing list server --
what I want to do is equivalent to processing a 
    Subject: subscribe name(_at_)domain
except that I only want to honor requests whose specified address is
within foo.bar and is reasonable.
If someone has this at their fingertips, I would greatly appreciate
seeing it.

The following examples were suggested:
* ^(From |Return-Path:).*@([-a-z0-9]+\.)*foo\.bar([^-a-z0-9.]|$)
* ^Received:.*[^-a-z0-9]foo\.bar([^-a-z0-9.]|$)

These examples indicate to me that only [-a-z0-9.] are acceptable in the
domain; i.e. all else, including "_" are unacceptable.  Also, the
leading character of a machine-name or domain-name doesn't necessarily
need to be [a-z].  
Not knowing better, I had thought that "_" was acceptable, and, the
leading character needed to be [a-z].  Now I remember that Don Libes
recommended against leading [0-9] in some RFC (1178?), but, it wasn't
forbidden.

So, instead of my original
    * ^Subject: send-weather-report \/[a-z].*@([a-z][a-z0-9_-]*\.)*foo\.bar$

I will use
    * ^Subject: send-weather-report \/[a-z0-9_.-]+@([a-z0-9-]+\.)*foo\.bar$

(unless someone recommends further improvements -- or points me to a 
fragment from "subscribe address" processing)

I now realize that restricting username to [a-z0-9_.-]+ isn't
RFC-blessed, but I'm not prepared to handle embedded/quoted whitespace
or commas, etc., so I must somewhat restrictive.

Thank you for your comments, I did learn quite a lot.  The
signal-to-noise ratio on this list seems quite good.  I like to hope
that the informative responses to my inquiry (signal) outweigh my
inquiry (noise).

Best regards,
John Ruckstuhl