Closed
Description
Step to reproduce:
>>> from w3lib.url import safe_url_string
>>> safe_url_string('http://新华网.中国')
'http://xn--xkrr14bows.xn--fiqs8s'
>>> safe_url_string('http://新华网.中国:80')
'http://xn--xkrr14bows.xn--:80-u68dy61b'
safe_url_string('http://新华网.中国:80')
expected result:
'http://xn--xkrr14bows.xn--fiqs8s:80'
real result:
'http://xn--xkrr14bows.xn--:80-u68dy61b'
Related code:
Line 80 in ef5c110
netloc = parts.netloc.encode('idna')
Maybe IDNA encoding should be done on hostname rather than netloc.