mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Enable UTS46 mode.
This commit is contained in:
+1
-1
@@ -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
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user