]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
accept the unknown RR syntax for known RR types
authorBob Halley <halley@dnspython.org>
Fri, 2 Sep 2005 05:22:31 +0000 (05:22 +0000)
committerBob Halley <halley@dnspython.org>
Fri, 2 Sep 2005 05:22:31 +0000 (05:22 +0000)
Original author: Bob Halley <halley@dnspython.org>
Date: 2004-05-14 08:33:47

ChangeLog
dns/rdata.py
dns/tokenizer.py
tests/example
tests/example1.good
tests/example2.good

index 2b430a1c88503c3c7c3f46b015aaa08b83c9f879..1cbfbeb63dc78fb2c4b1698bfcab3650dfa18577 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2004-05-14  Bob Halley  <halley@dnspython.org>
+
+       * dns/rdata.py (from_text): The masterfile reader did not
+       accept the unknown RR syntax when used with a known RR type.
+
+2004-05-08  Bob Halley  <halley@dnspython.org>
+
+       * dns/name.py (from_text): dns.name.from_text() did not raise
+       an exception if a backslash escape ended prematurely.
+
 2004-04-09  Bob Halley  <halley@dnspython.org>
 
        * dns/zone.py (_MasterReader._rr_line): The masterfile reader
index eebcdbc5e5e0d0ed90aaed644cee27c99935d91f..1d096d20ae413f1af865c4208adf8c28286fb050 100644 (file)
@@ -399,6 +399,21 @@ def from_text(rdclass, rdtype, tok, origin = None, relativize = True):
     if isinstance(tok, str):
         tok = dns.tokenizer.Tokenizer(tok)
     cls = get_rdata_class(rdclass, rdtype)
+    if cls != GenericRdata:
+        # peek at first token
+        token = tok.get()
+        tok.unget(token)
+        if token[0] == dns.tokenizer.IDENTIFIER and \
+           token[1] == r'\#':
+            #
+            # Known type using the generic syntax.  Extract the
+            # wire form from the generic syntax, and then run
+            # from_wire on it.
+            #
+            rdata = GenericRdata.from_text(rdclass, rdtype, tok, origin,
+                                           relativize)
+            return from_wire(rdclass, rdtype, rdata.data, 0, len(rdata.data),
+                             origin)
     return cls.from_text(rdclass, rdtype, tok, origin, relativize)
 
 def from_wire(rdclass, rdtype, wire, current, rdlen, origin = None):
index ad078ff8c562750b86d8cd977849677c2e8ac0c6..a61fa85e88f5ae6dde07f90cb960f12b80fcd78a 100644 (file)
@@ -59,7 +59,7 @@ class Tokenizer(object):
     @ivar ungotten_char: The most recently ungotten character, or None.
     @type ungotten_char: string
     @ivar ungotten_token: The most recently ungotten token, or None.
-    @type ungotten_token: string
+    @type ungotten_token: (int, string) token tuple
     @ivar multiline: The current multiline level.  This value is increased
     by one every time a '(' delimiter is read, and decreased by one every time
     a ')' delimiter is read.
@@ -302,8 +302,8 @@ class Tokenizer(object):
         empty.
         
         @param token: the token to unget
-        @type token: string
-        @raises UngetBufferFull: there is already an ungotten char
+        @type token: (int, string) token tuple
+        @raises UngetBufferFull: there is already an ungotten token
         """
 
         if not self.ungotten_token is None:
index f57e968f4770c5cd1e5abb57fc0ae96e9fb368aa..c34b5a64aaf37a48e7c929765519aadcbf50ff8f 100644 (file)
@@ -197,3 +197,7 @@ dnskey02            DNSKEY  HOST|FLAG4 DNSSEC RSAMD5 (
                                yzWZriO6i2odGWWQVucZqKVsENW91IOW4vqudngPZsY3
                                GvQ/xVA8/7pyFj6b7Esga60zyGW6LFe9r8n6paHrlG5o
                                jqf0BaqHT+8= )
+;
+; test known type using unknown RR syntax
+;
+unknown3               A       \# 4 7f000002
index 610aee6a3b2f95a350bd0d97226f595381644cdc..c57bb65d2eee2e241605f1aba75e0d0683c505bb 100644 (file)
@@ -95,6 +95,7 @@ u 300 IN TXT "txt-not-in-nxt"
 a.u 300 IN A 73.80.65.49
 b.u 300 IN A 73.80.65.49
 unknown2 3600 IN TYPE999 \# 8 0a0000010a000001
+unknown3 3600 IN A 127.0.0.2
 wks01 3600 IN WKS 10.0.0.1 6 0 1 2 21 23
 wks02 3600 IN WKS 10.0.0.1 17 0 1 2 53
 wks03 3600 IN WKS 10.0.0.2 6 65535
index feec82a61afdbdbad80191a4abef77ab0f6b25a7..88549a3c5cf41bc8b0cc3e6197dd59c82d27e7c5 100644 (file)
@@ -95,6 +95,7 @@ u.example. 300 IN TXT "txt-not-in-nxt"
 a.u.example. 300 IN A 73.80.65.49
 b.u.example. 300 IN A 73.80.65.49
 unknown2.example. 3600 IN TYPE999 \# 8 0a0000010a000001
+unknown3.example. 3600 IN A 127.0.0.2
 wks01.example. 3600 IN WKS 10.0.0.1 6 0 1 2 21 23
 wks02.example. 3600 IN WKS 10.0.0.1 17 0 1 2 53
 wks03.example. 3600 IN WKS 10.0.0.2 6 65535