summaryrefslogtreecommitdiffstats
path: root/Lib/urllib/parse.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2017-12-21 12:54:45 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2017-12-21 12:54:45 (GMT)
commitfdb148f949e3ae66036b75163ff68042d19cf0fc (patch)
tree1f3155f4f2f257563b8a934983785d9d5b5029ff /Lib/urllib/parse.py
parent45588c6dd1e8644abf7dde42f566a8f81c7cc4f0 (diff)
downloadcpython-fdb148f949e3ae66036b75163ff68042d19cf0fc.zip
cpython-fdb148f949e3ae66036b75163ff68042d19cf0fc.tar.gz
cpython-fdb148f949e3ae66036b75163ff68042d19cf0fc.tar.bz2
bpo-32323: urllib.parse.urlsplit() must not lowercase() IPv6 scope value (GH-4867) (#4959)
(cherry picked from commit fbd605151fcf2899b14575f4ddb9ce3c55e684ab)
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 3cab2d1..f959212 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):