From: Martin Basti Date: Wed, 19 Nov 2014 13:43:06 +0000 (+0100) Subject: Fix name.from_unicode to raise prorper exception X-Git-Tag: v1.13.0~30^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bed9d532bee9b88231c83a1e9e465b5249d1df1b;p=thirdparty%2Fdnspython.git Fix name.from_unicode to raise prorper exception Without this fix, UnicodeError exception was raised instead of LabelTooLong --- 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: