diff options
author | Bob Halley <halley@dnspython.org> | 2014-06-21 07:45:14 -0700 |
---|---|---|
committer | Bob Halley <halley@dnspython.org> | 2014-06-21 07:45:14 -0700 |
commit | 56ab1a15c8d4b6a26e0643e5ce3aac7e09f2c9b5 (patch) | |
tree | f316ea4894c049408cbb199efba8bb8dc04e71d4 | |
parent | f962db12ce3cb46ae61ef3e55ad8369be30447ec (diff) | |
download | dnspython-56ab1a15c8d4b6a26e0643e5ce3aac7e09f2c9b5.tar.gz |
Fix exception when reading from a masterfile.
When reading from a masterfile, if the first content line started
with leading whitespace, we raised an ugly exception instead of
doing the right thing, namely using the zone origin as the name.
[#73]
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | dns/zone.py | 2 | ||||
-rw-r--r-- | tests/test_zone.py | 11 |
3 files changed, 18 insertions, 2 deletions
@@ -1,3 +1,10 @@ +2014-06-21 Bob Halley <halley@dnspython.org> + + * When reading from a masterfile, if the first content line started + with leading whitespace, we raised an ugly exception instead of + doing the right thing, namely using the zone origin as the name. + [#73] + 2014-06-19 Bob Halley <halley@dnspython.org> * Escaping of Unicode has been corrected. Previously we escaped and diff --git a/dns/zone.py b/dns/zone.py index ab57148..6f34483 100644 --- a/dns/zone.py +++ b/dns/zone.py @@ -558,7 +558,7 @@ class _MasterReader(object): self.current_origin = origin self.relativize = relativize self.ttl = 0 - self.last_name = None + self.last_name = self.current_origin self.zone = zone_factory(origin, rdclass, relativize=relativize) self.saved_state = [] self.current_file = None diff --git a/tests/test_zone.py b/tests/test_zone.py index 31e7405..551530a 100644 --- a/tests/test_zone.py +++ b/tests/test_zone.py @@ -129,7 +129,7 @@ class ZoneTestCase(unittest.TestCase): for n in names: print >> f, z[n].to_text(n) self.failUnless(f.getvalue() == example_text_output) - + def testTorture1(self): # # Read a zone containing all our supported RR types, and @@ -385,5 +385,14 @@ class ZoneTestCase(unittest.TestCase): relativize=True) self.failUnlessRaises(dns.exception.SyntaxError, bad) + def testFirstRRStartsWithWhitespace(self): + # no name is specified, so default to the intial origin + # no ttl is specified, so default to the initial TTL of 0 + z = dns.zone.from_text(' IN A 10.0.0.1', origin='example.', + check_origin=False) + n = z['@'] + rds = n.get_rdataset(dns.rdataclass.IN, dns.rdatatype.A) + self.failUnless(rds.ttl == 0) + if __name__ == '__main__': unittest.main() |