From: Bob Halley Date: Sat, 7 Apr 2012 21:09:05 +0000 (+0100) Subject: allow whitespace in SSHFP fingerprints X-Git-Tag: v1.10.0-py3~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ab9852e14cda6d3b1f91a66c929b19c4eaf4b9e;p=thirdparty%2Fdnspython.git allow whitespace in SSHFP fingerprints --- diff --git a/ChangeLog b/ChangeLog index accd9b19..46064a5f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2012-04-07 Bob Halley + * dns/rdtypes/ANY/SSHFP.py (SSHFP.from_text): Allow whitespace in + the text string. Thanks to Jan Andres for the report and the + patch. + * dns/message.py (from_wire): dns.message.from_wire() now takes an 'ignore_trailing' parameter which defaults to False. If set to True, then trailing junk will be ignored instead of causing diff --git a/dns/rdtypes/ANY/SSHFP.py b/dns/rdtypes/ANY/SSHFP.py index ab870542..b7ee2544 100644 --- a/dns/rdtypes/ANY/SSHFP.py +++ b/dns/rdtypes/ANY/SSHFP.py @@ -48,8 +48,16 @@ class SSHFP(dns.rdata.Rdata): def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True): algorithm = tok.get_uint8() fp_type = tok.get_uint8() - fingerprint = bytes.fromhex(tok.get_string()) - tok.get_eol() + chunks = [] + while 1: + t = tok.get().unescape() + if t.is_eol_or_eof(): + break + if not t.is_identifier(): + raise dns.exception.SyntaxError + chunks.append(t.value) + hex = ''.join(chunks) + fingerprint = bytes.fromhex(hex) return cls(rdclass, rdtype, algorithm, fp_type, fingerprint) from_text = classmethod(from_text)