]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
add $ to allow_directives if missing 833/head
authorBob Halley <halley@dnspython.org>
Tue, 16 Aug 2022 23:44:35 +0000 (16:44 -0700)
committerBob Halley <halley@dnspython.org>
Tue, 16 Aug 2022 23:44:35 +0000 (16:44 -0700)
dns/zonefile.py
tests/test_zone.py

index 3d3aa61d9b5df92f0813253c294e0d5a6a0df27e..a17ebff2c6f6dc0171ed52817f5513a292ae7727 100644 (file)
@@ -79,6 +79,13 @@ SavedStateType = Tuple[
 ]  # default_ttl_known
 
 
+def _upper_dollarize(s):
+    s = s.upper()
+    if not s.startswith("$"):
+        s = "$" + s
+    return s
+
+
 class Reader:
 
     """Read a DNS zone file into a transaction."""
@@ -126,7 +133,7 @@ class Reader:
         else:
             # Note that if directives are explicitly specified, then allow_include
             # is ignored.
-            self.allowed_directives = set(d.upper() for d in allow_directives)
+            self.allowed_directives = set(_upper_dollarize(d) for d in allow_directives)
         self.force_name = force_name
         self.force_ttl = force_ttl
         self.force_rdclass = force_rdclass
index 5dfa6ff00079d77a0d172f74786fd074ac8723c7..6b9e2b5eb2418034c6c34ea69ac239960f2dc1e5 100644 (file)
@@ -872,6 +872,16 @@ class ZoneTestCase(unittest.TestCase):
         z2 = dns.zone.from_file(here("example"), "example.", relativize=True)
         self.assertEqual(z1, z2)
 
+    def testExplicitIncludeNotUpperNoDollar(self):
+        z1 = dns.zone.from_text(
+            include_text,
+            "example.",
+            relativize=True,
+            allow_directives={"InClUdE", "origin", "TTL"},
+        )
+        z2 = dns.zone.from_file(here("example"), "example.", relativize=True)
+        self.assertEqual(z1, z2)
+
     def testExplicitLowerCase(self):
         z1 = dns.zone.from_text(
             include_text,