Re: Why does host and dig show a ; as \;?

From: Doug Barton <dougb_at_FreeBSD.org>
Date: Sun, 14 Dec 2008 18:21:21 -0800
Eygene Ryabinkin wrote:
> Larry, good day.
> 
> Tue, Dec 09, 2008 at 01:49:27PM -0600, Larry Rosenman wrote:
>> On Tue, 9 Dec 2008, Dimitry Andric wrote:
>>> On 2008-12-09 17:36, Larry Rosenman wrote:
>>>> Why does the host command, dig, and a named_db.dump all show a ; as \; in a
>>>> TXT record?
>>> AFAICS the semicolon is a comment character in BIND software (at least
>>> in all config files and so on), and therefore it needs to be escaped.
> 
> It doesn't need to be escaped inside strings themselves, at least there
> is no reason to have comments inside strings and BIND itself treats ';'
> inside strings as ordinary characters.  But BIND's internal helper
> txt_totext does the escaping:
> ----- lib/dns/rdata.c
>                 /* double quote, semi-colon, backslash */
>                 if (*sp == 0x22 || *sp == 0x3b || *sp == 0x5c) {
>                         if (tl < 2)
>                                 return (ISC_R_NOSPACE);
>                         *tp++ = '\\';
>                         tl--;
>                 }
> -----
> And BIND understands both escaped and unescaped semicolons inside
> strings in zone files -- it treats both of them in a same way.
> 
> I don't have access to BIND's CVSWeb interface, so I can not trace the
> origin of semicolon escaping, but I feel that historically BIND treated
> semicolons inside strings as the plain symbols and this remained so to
> be backwards-compatible.  And escaping in the BIND's output is the
> stricter form of string formatting.  However, for example, our Russian
> TLD registrars are suggesting to avoid escapes inside strings if it is
> possible.  Don't know why -- it is just a recipe without explanation.
> 
> I am CC'ing Doug Barton, who maintains BIND for FreeBSD.  Doug, is there
> any requirement for escaping the semicolons inside strings?  I am
> failing to find it in http://www.ietf.org/rfc/rfc1035.txt: it talks
> about semicolons, but not about escaping and there seems to be no proper
> BNF notation for DNS zone files.  Am I missing something?

I've never come across this, but if I had to guess I'd say that it does
so for maximum compatibility with a wide variety of DNS software.
Remember the robustness principle, "liberal in what you accept,
conservative in what you send."

hth,

Doug


-- 

    This .signature sanitized for your protection
Received on Mon Dec 15 2008 - 01:48:08 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:38 UTC