From bed9d532bee9b88231c83a1e9e465b5249d1df1b Mon Sep 17 00:00:00 2001 From: Martin Basti Date: Wed, 19 Nov 2014 14:43:06 +0100 Subject: [PATCH] Fix name.from_unicode to raise prorper exception Without this fix, UnicodeError exception was raised instead of LabelTooLong --- dns/name.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dns/name.py b/dns/name.py index 5eb925d6..29baacab 100644 --- a/dns/name.py +++ b/dns/name.py @@ -587,6 +587,9 @@ def from_unicode(text, origin = root): c == u'\uff0e' or c == u'\uff61': if len(label) == 0: raise EmptyLabel + if len(label) > 63: + # otherwise encodings.idna raises UnicodeError later + raise LabelTooLong labels.append(encodings.idna.ToASCII(label)) label = u'' elif c == u'\\': @@ -597,6 +600,9 @@ def from_unicode(text, origin = root): label += c if escaping: raise BadEscape + if len(label) > 63: + # otherwise encodings.idna raises UnicodeError later + raise LabelTooLong if len(label) > 0: labels.append(encodings.idna.ToASCII(label)) else: -- 2.47.3