From: Bob Halley Date: Fri, 2 Sep 2005 05:22:23 +0000 (+0000) Subject: treat leading whitespace followed by EOL/EOF as a blank line X-Git-Tag: v1.3.4~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54fd6bc9dec868e903535d8164f255ae8d1b8712;p=thirdparty%2Fdnspython.git treat leading whitespace followed by EOL/EOF as a blank line Original author: Bob Halley Date: 2004-04-09 10:09:59 --- diff --git a/ChangeLog b/ChangeLog index 57b1b152..2b430a1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-04-09 Bob Halley + + * dns/zone.py (_MasterReader._rr_line): The masterfile reader + erroneously treated lines starting with leading whitespace but + not having any RR definition as an error. It now treats + them like a blank line (which is not an error). + +2004-04-01 Bob Halley + + * (Version 1.3.0 released) + 2004-03-19 Bob Halley * Added support for new DNSSEC types RRSIG, NSEC, and DNSKEY. diff --git a/dns/zone.py b/dns/zone.py index 711e26d1..002366b1 100644 --- a/dns/zone.py +++ b/dns/zone.py @@ -567,6 +567,13 @@ class _MasterReader(object): token = self.tok.get(want_leading = True) if token[0] != dns.tokenizer.WHITESPACE: self.last_name = dns.name.from_text(token[1], self.current_origin) + else: + token = self.tok.get() + if token[0] == dns.tokenizer.EOL or \ + token[0] == dns.tokenizer.EOF: + # treat leading WS followed by EOL/EOF as if they were EOL/EOF. + return + self.tok.unget(token) name = self.last_name if not name.is_subdomain(self.zone.origin): self._eat_line() diff --git a/tests/example b/tests/example index 1b96f1bd..f57e968f 100644 --- a/tests/example +++ b/tests/example @@ -33,6 +33,13 @@ $ORIGIN example. * MX 10 mail a TXT "foo foo foo" PTR foo.net. +;; The next line not starting with ';;' is leading whitespace followed by +;; EOL. We want to treat that as if EOL had appeared alone. + +;; The next line not starting with ';;' is leading whitespace followed by +;; a comment followed by EOL. We want to treat that as if EOL had appeared +;; alone. + ; foo $TTL 3600 ; 1 hour a01 A 0.0.0.0 a02 A 255.255.255.255