summaryrefslogtreecommitdiffstats
path: root/Lib/urllib/parse.py
diff options
context:
space:
mode:
authorКоренберг Марк <socketpair@gmail.com>2017-12-21 12:16:17 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2017-12-21 12:16:17 (GMT)
commitfbd605151fcf2899b14575f4ddb9ce3c55e684ab (patch)
tree33c8d17b6cc9fd44c5471860c16b7fdc02e67eaa /Lib/urllib/parse.py
parenta8d25a16452f7ee8dfc350cd028b3ae172d28ada (diff)
downloadcpython-fbd605151fcf2899b14575f4ddb9ce3c55e684ab.zip
cpython-fbd605151fcf2899b14575f4ddb9ce3c55e684ab.tar.gz
cpython-fbd605151fcf2899b14575f4ddb9ce3c55e684ab.tar.bz2
bpo-32323: urllib.parse.urlsplit() must not lowercase() IPv6 scope value (#4867)
Diffstat (limited to 'Lib/urllib/parse.py')
-rw-r--r--Lib/urllib/parse.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index 76086e5..58460f9 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -155,10 +155,12 @@ class _NetlocResultMixinBase(object):
def hostname(self):
hostname = self._hostinfo[0]
if not hostname:
- hostname = None
- elif hostname is not None:
- hostname = hostname.lower()
- return hostname
+ return None
+ # Scoped IPv6 address may have zone info, which must not be lowercased
+ # like http://[fe80::822a:a8ff:fe49:470c%tESt]:1234/keys
+ separator = '%' if isinstance(hostname, str) else b'%'
+ hostname, percent, zone = hostname.partition(separator)
+ return hostname.lower() + percent + zone
@property
def port(self):