Regexp issue in NAPTR rewrite

sandoche BALAKRICHENAN sandoche.balakrichenan at afnic.fr
Wed May 13 07:13:55 UTC 2009


Mark Andrews wrote:
> 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".
>   

Thanks. With double "\\" it works.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: sandoche_balakrichenan.vcf
Type: text/x-vcard
Size: 230 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/bind-users/attachments/20090513/8c288df7/attachment.vcf>


More information about the bind-users mailing list