Regexp issue in NAPTR rewrite
Mark Andrews
Mark_Andrews at isc.org
Tue May 12 22:23:44 UTC 2009
In message <4A093B9C.5060100 at afnic.fr>, sandoche BALAKRICHENAN writes:
>
> I want to rewrite a query of the form
> "sgtin.5.4.0.0.0.1.3.2.4.5.6.7.6.id.onsam.test" to
> "sgtin.5.4.0.0.0.1.3.2.4.5.6.7.6.id.onseu.test" using NAPTR rewrite.
>
> The NAPTR RR in the zone config is as follows:
>
> sgtin.5.4.0.0.0.1.3.2.4.5.6.7.6.id.onsam.test IN NAPTR
> 0 0 "r" "" "!^sgtin\.([0-9])$!\1.id.onseu.test!" .
>
> BIND does not accept backref "\1" . It shows a syntax error.
>
> Is the above regexp correct?
You failed to properly escape the string.
>From RFC2168.
Recall that the regular expression used \2 to extract a domain name
from the CID, and \. for matching the literal '.' characters
seperating the domain name components. Since '\' is the escape
character, literal occurances of a backslash must be escaped by
another backslash. For the case of the cid.urn.net record above, the
regular expression entered into the zone file should be
"/urn:cid:.+@([^\\.]+\\.)(.*)$/\\2/i". When the client code actually
receives the record, the pattern will have been converted to
"/urn:cid:.+@([^.]+\.)(.*)$/\2/i".
--
Mark Andrews, ISC
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742 INTERNET: Mark_Andrews at isc.org
More information about the bind-users
mailing list