prevent error when converting idn to ascii strings. Fixes #7995

This commit is contained in:
Yann Leboulanger 2015-03-25 10:05:29 +01:00
parent a17ff4b45e
commit 512840944b
1 changed files with 4 additions and 1 deletions

View File

@ -123,7 +123,10 @@ def idn_to_ascii(host):
labels = idna.dots.split(host)
converted_labels = []
for label in labels:
converted_labels.append(idna.ToASCII(label).decode('utf-8'))
if label:
converted_labels.append(idna.ToASCII(label).decode('utf-8'))
else:
converted_labels.append('')
return ".".join(converted_labels)
def ascii_to_idn(host):