]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Fix exception when reading from a masterfile.
authorBob Halley <halley@dnspython.org>
Mon, 1 Sep 2014 00:02:56 +0000 (17:02 -0700)
committerBob Halley <halley@dnspython.org>
Mon, 1 Sep 2014 00:02:56 +0000 (17:02 -0700)
dns/zone.py
tests/zone.py

index a5f4f9c1fc441edcca001faed7c3bd30e99baec6..9a8fc226829b4e722828d5e636e7cbc20f9fbfe2 100644 (file)
@@ -565,7 +565,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
index 61f414806d3864b0ee1280993a005c63bc3deaab..67fc2ae6a004e14b93dcf8456aec660bc2e3489e 100644 (file)
@@ -394,5 +394,14 @@ class ZoneTestCase(unittest.TestCase):
                                    relativize=True)
         self.assertRaises(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.assertTrue(rds.ttl == 0)
+
 if __name__ == '__main__':
     unittest.main()