diff options
author | Seth Michael Larson <sethmichaellarson@gmail.com> | 2019-04-21 19:56:42 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-21 19:56:42 -0500 |
commit | bbeeae20cc9af5f9c833da8d35a95a42fad8393e (patch) | |
tree | 7f28cb3ec9ec2b9375b2604c738c74bc3ccd63c9 | |
parent | 5d523706c7b03f947dc50a7e783758a2bfff0532 (diff) | |
download | urllib3-bbeeae20cc9af5f9c833da8d35a95a42fad8393e.tar.gz |
Apply lowercasing before IDNA-encoding (#1569)
-rw-r--r-- | src/urllib3/util/url.py | 2 | ||||
-rw-r--r-- | test/test_util.py | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/urllib3/util/url.py b/src/urllib3/util/url.py index 0127e2fe..de3c4686 100644 --- a/src/urllib3/util/url.py +++ b/src/urllib3/util/url.py @@ -183,7 +183,7 @@ def parse_url(url): except ImportError: raise LocationParseError("Unable to parse URL without the 'idna' module") try: - return idna.encode(name, strict=True, std3_rules=True).lower() + return idna.encode(name.lower(), strict=True, std3_rules=True) except idna.IDNAError: raise LocationParseError(u"Name '%s' is not a valid IDNA label" % name) return name diff --git a/test/test_util.py b/test/test_util.py index b8ab2e68..c86170cf 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -211,6 +211,10 @@ class TestUtil(object): # Empty Port ('http://google.com:', Url('http', host='google.com')), ('http://google.com:/', Url('http', host='google.com', path='/')), + + # Uppercase IRI + (u'http://Königsgäßchen.de/straße', + Url('http', host='xn--knigsgchen-b4a3dun.de', path='/stra%C3%9Fe')) ] @pytest.mark.parametrize( |