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

From: Eygene Ryabinkin <rea-fbsd_at_codelabs.ru>
Date: Wed, 10 Dec 2008 10:55:51 +0300
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?

Thanks!
-- 
Eygene
 _                ___       _.--.   #
 \`.|\..----...-'`   `-._.-'_.-'`   #  Remember that it is hard
 /  ' `         ,       __.--'      #  to read the on-line manual   
 )/' _/     \   `-_,   /            #  while single-stepping the kernel.
 `-'" `"\_  ,_.-;_.-\_ ',  fsc/as   #
     _.-'_./   {_.'   ; /           #    -- FreeBSD Developers handbook 
    {_.-``-'         {_/            #

Received on Wed Dec 10 2008 - 06:55:55 UTC

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