]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Fix name.from_unicode to raise prorper exception 83/head
authorMartin Basti <mbasti@redhat.com>
Wed, 19 Nov 2014 13:43:06 +0000 (14:43 +0100)
committerMartin Basti <mbasti@redhat.com>
Wed, 19 Nov 2014 13:43:06 +0000 (14:43 +0100)
Without this fix, UnicodeError exception was raised instead of
LabelTooLong

dns/name.py

index 5eb925d64fdb4d94df7cd7bbe309bcd426022a1d..29baacab50d8e1d9dfd879cf7f1b4af3d4e1234e 100644 (file)
@@ -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: