]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Update zone.py
authortmerila <tuomas@merila.org>
Wed, 3 Apr 2019 10:57:15 +0000 (13:57 +0300)
committerGitHub <noreply@github.com>
Wed, 3 Apr 2019 10:57:15 +0000 (13:57 +0300)
By doing the TTL validity check after parsing the record data allows the TTL to be set properly from SOA RDATA even when the SOA record itself does not have TTL set.

dns/zone.py

index 21731a6a840f1d9e8625247ec16901d5fc97cd43..e80a3ca2fb62971e147b85e0908f348d0dcd97f0 100644 (file)
@@ -658,21 +658,7 @@ class _MasterReader(object):
         token = self.tok.get()
         if not token.is_identifier():
             raise dns.exception.SyntaxError
-        # TTL
-        try:
-            ttl = dns.ttl.from_text(token.value)
-            self.last_ttl = ttl
-            self.last_ttl_known = True
-            token = self.tok.get()
-            if not token.is_identifier():
-                raise dns.exception.SyntaxError
-        except dns.ttl.BadTTL:
-            if not (self.last_ttl_known or self.default_ttl_known):
-                raise dns.exception.SyntaxError("Missing default TTL value")
-            if self.default_ttl_known:
-                ttl = self.default_ttl
-            else:
-                ttl = self.last_ttl
+
         # Class
         try:
             rdclass = dns.rdataclass.from_text(token.value)
@@ -719,6 +705,22 @@ class _MasterReader(object):
             self.default_ttl = rd.minimum
             self.default_ttl_known = True
 
+        # TTL
+        try:
+            ttl = dns.ttl.from_text(token.value)
+            self.last_ttl = ttl
+            self.last_ttl_known = True
+            token = self.tok.get()
+            if not token.is_identifier():
+                raise dns.exception.SyntaxError
+        except dns.ttl.BadTTL:
+            if not (self.last_ttl_known or self.default_ttl_known):
+                raise dns.exception.SyntaxError("Missing default TTL value")
+            if self.default_ttl_known:
+                ttl = self.default_ttl
+            else:
+                ttl = self.last_ttl
+            
         rd.choose_relativity(self.zone.origin, self.relativize)
         covers = rd.covers()
         rds = n.find_rdataset(rdclass, rdtype, covers, True)