Dallman Ross wrote Sunday, January 25, 2009 19:21:
# find TLD or country-style-format TLD.
# Example: "com"; "org"; "co.uk"
:0
* $ FQDN ?? $\DOMPART[.]\/.+
{ TLD = $MATCH }
There is a possible bug here if the domain part repeats.
So "foo.bar.example.foo.bar.example.com" will have the
TLD part misparsed. Example run showing bug:
7:45pm [~/Mail/dev] 632[0]> procmail -m rc.domainparts panix5.panix.$HOST
mars.example.mars.example.co.uk < /dev/null
FQDN is >panix5.panix.panix5.panix.com<
DOMPART is >panix<
TLD is >panix5.panix.com<
---
FQDN is >mars.example.mars.example.co.uk<
DOMPART is >example<
TLD is >mars.example.co.uk<
---
Here is the tightened code for
this part of the offered syntax:
# find TLD or country-style-format TLD.
# Example: "com"; "org"; "co.uk"
:0
* $ FQDN ?? $\DOMPART[.]\/[^.]+[.]?[^.]+^^
{ TLD = $MATCH }
Now it works as advertised even under the previous bug-inducing
condition:
7:48pm [~/Mail/dev] 634[0]> procmail -m rc.domainparts panix5.panix.$HOST
mars.example.mars.example.co.uk < /dev/null
FQDN is >panix5.panix.panix5.panix.com<
DOMPART is >panix<
TLD is >com<
---
FQDN is >mars.example.mars.example.co.uk<
DOMPART is >example<
TLD is >co.uk<
Dallman
____________________________________________________________
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