[Gajim-devel] UnicodeError: label empty or too long

Ruslan Makhmatkhanov cvs-src at yandex.ru
Wed Jul 1 17:26:29 CEST 2015


Hello,

I got "UnicodeError: label empty or too long" on some messages in 
history. Actual crash happens in idn_to_ascii:

   File "/usr/local/share/gajim/src/common/helpers.py", line 125, in 
idn_to_ascii
      converted_labels.append(idna.ToASCII(label))
    File "/usr/local/lib/python2.7/encodings/idna.py", line 73, in ToASCII
      raise UnicodeError("label empty or too long")

Patch attached fixing it (just be sure that label is not empty before 
calling idna.ToASCII()).

-- 
Regards,
Ruslan

T.O.S. Of Reality

-------------- next part --------------
diff --git a/helpers.py.orig b/helpers.py
index 9c46cc9..48947fc 100644
--- a/helpers.py.orig
+++ b/helpers.py
@@ -122,7 +122,8 @@ def idn_to_ascii(host):
     labels = idna.dots.split(host)
     converted_labels = []
     for label in labels:
-        converted_labels.append(idna.ToASCII(label))
+        if label:
+            converted_labels.append(idna.ToASCII(label))
     return ".".join(converted_labels)
 
 def ascii_to_idn(host):


More information about the Gajim-devel mailing list