Enable UTS46 mode.

This commit is contained in:
Cory Benfield
2016-10-14 15:13:37 +01:00
parent 110684ea02
commit 8dd51d22fc
2 changed files with 13 additions and 2 deletions
+1 -1
View File
@@ -364,7 +364,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
# Only want to apply IDNA to the hostname
try:
host = idna.encode(host).decode('utf-8')
host = idna.encode(host, uts46=True).decode('utf-8')
except (UnicodeError, idna.IDNAError):
raise InvalidURL('URL has an invalid label.')
+12 -1
View File
@@ -1900,11 +1900,22 @@ class TestPreparingURLs(object):
u'http://ジェーピーニック.jp'.encode('utf-8'),
u'http://xn--hckqz9bzb1cyrb.jp/'
),
(u'http://straße.de/straße', u'http://xn--strae-oqa.de/stra%C3%9Fe'),
(
u'http://straße.de/straße',
u'http://xn--strae-oqa.de/stra%C3%9Fe'
),
(
u'http://straße.de/straße'.encode('utf-8'),
u'http://xn--strae-oqa.de/stra%C3%9Fe'
),
(
u'http://Königsgäßchen.de/straße',
u'http://xn--knigsgchen-b4a3dun.de/stra%C3%9Fe'
),
(
u'http://Königsgäßchen.de/straße'.encode('utf-8'),
u'http://xn--knigsgchen-b4a3dun.de/stra%C3%9Fe'
),
)
)
def test_preparing_url(self, url, expected):