From 2ab9852e14cda6d3b1f91a66c929b19c4eaf4b9e Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Sat, 7 Apr 2012 22:09:05 +0100 Subject: [PATCH] allow whitespace in SSHFP fingerprints --- ChangeLog | 4 ++++ dns/rdtypes/ANY/SSHFP.py | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) 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) -- 2.47.3