From: Bob Halley Date: Fri, 2 Sep 2005 05:22:31 +0000 (+0000) Subject: accept the unknown RR syntax for known RR types X-Git-Tag: v1.3.4~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07c1fb5c5f054bf12ec5835afb94e5681112715a;p=thirdparty%2Fdnspython.git accept the unknown RR syntax for known RR types Original author: Bob Halley Date: 2004-05-14 08:33:47 --- diff --git a/ChangeLog b/ChangeLog index 2b430a1c..1cbfbeb6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-05-14 Bob Halley + + * 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 + + * 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 * dns/zone.py (_MasterReader._rr_line): The masterfile reader diff --git a/dns/rdata.py b/dns/rdata.py index eebcdbc5..1d096d20 100644 --- a/dns/rdata.py +++ b/dns/rdata.py @@ -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): diff --git a/dns/tokenizer.py b/dns/tokenizer.py index ad078ff8..a61fa85e 100644 --- a/dns/tokenizer.py +++ b/dns/tokenizer.py @@ -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: diff --git a/tests/example b/tests/example index f57e968f..c34b5a64 100644 --- a/tests/example +++ b/tests/example @@ -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 diff --git a/tests/example1.good b/tests/example1.good index 610aee6a..c57bb65d 100644 --- a/tests/example1.good +++ b/tests/example1.good @@ -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 diff --git a/tests/example2.good b/tests/example2.good index feec82a6..88549a3c 100644 --- a/tests/example2.good +++ b/tests/example2.good @@ -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