From fbd605151fcf2899b14575f4ddb9ce3c55e684ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BE=D1=80=D0=B5=D0=BD=D0=B1=D0=B5=D1=80=D0=B3=20?= =?UTF-8?q?=D0=9C=D0=B0=D1=80=D0=BA?= Date: Thu, 21 Dec 2017 17:16:17 +0500 Subject: bpo-32323: urllib.parse.urlsplit() must not lowercase() IPv6 scope value (#4867) --- Lib/urllib/parse.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Lib/urllib/parse.py') diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index 76086e58be..58460f9234 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): -- cgit v1.2.1