This commit is contained in:
Miroslav Stampar
2019-11-22 15:20:45 +01:00
parent 9c87671e3a
commit 6e46624fe0
3 changed files with 10 additions and 5 deletions

View File

@@ -4360,11 +4360,16 @@ def asciifyUrl(url, forceQuote=False):
if all(char in string.printable for char in url):
return getText(url)
hostname = parts.hostname
if isinstance(hostname, six.binary_type):
hostname = getUnicode(hostname)
# idna-encode domain
try:
hostname = parts.hostname.encode("idna")
except LookupError:
hostname = parts.hostname.encode("punycode")
hostname = hostname.encode("idna")
except:
hostname = hostname.encode("punycode")
# UTF8-quote the other parts. We check each part individually if
# if needs to be quoted - that should catch some additional user