b57490563c
Fixes CVE-2019-10160: urlsplit does not handle NFKC normalization (2nd fix) While the fix for CVE-2019-9936 is included in 3.7.3, the followup regression fixes unfortunatly aren't. https://bugs.python.org/issue36742 Signed-off-by: Peter Korsgaard <peter@korsgaard.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
59 lines
2.5 KiB
Diff
59 lines
2.5 KiB
Diff
From 250b62acc59921d399f0db47db3b462cd6037e09 Mon Sep 17 00:00:00 2001
|
|
From: "Miss Islington (bot)"
|
|
<31488909+miss-islington@users.noreply.github.com>
|
|
Date: Tue, 4 Jun 2019 09:15:13 -0700
|
|
Subject: [PATCH] bpo-36742: Corrects fix to handle decomposition in usernames
|
|
(GH-13812)
|
|
|
|
(cherry picked from commit 8d0ef0b5edeae52960c7ed05ae8a12388324f87e)
|
|
|
|
Co-authored-by: Steve Dower <steve.dower@python.org>
|
|
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
|
|
---
|
|
Lib/test/test_urlparse.py | 11 ++++++-----
|
|
Lib/urllib/parse.py | 6 +++---
|
|
2 files changed, 9 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py
|
|
index c262354494..68f633ca3a 100644
|
|
--- a/Lib/test/test_urlparse.py
|
|
+++ b/Lib/test/test_urlparse.py
|
|
@@ -1008,11 +1008,12 @@ class UrlParseTestCase(unittest.TestCase):
|
|
urllib.parse.urlsplit('http://\u30d5\u309a\ufe1380')
|
|
|
|
for scheme in ["http", "https", "ftp"]:
|
|
- for c in denorm_chars:
|
|
- url = "{}://netloc{}false.netloc/path".format(scheme, c)
|
|
- with self.subTest(url=url, char='{:04X}'.format(ord(c))):
|
|
- with self.assertRaises(ValueError):
|
|
- urllib.parse.urlsplit(url)
|
|
+ for netloc in ["netloc{}false.netloc", "n{}user@netloc"]:
|
|
+ for c in denorm_chars:
|
|
+ url = "{}://{}/path".format(scheme, netloc.format(c))
|
|
+ with self.subTest(url=url, char='{:04X}'.format(ord(c))):
|
|
+ with self.assertRaises(ValueError):
|
|
+ urllib.parse.urlsplit(url)
|
|
|
|
class Utility_Tests(unittest.TestCase):
|
|
"""Testcase to test the various utility functions in the urllib."""
|
|
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
|
|
index f5b3487ea9..4c8e77fe39 100644
|
|
--- a/Lib/urllib/parse.py
|
|
+++ b/Lib/urllib/parse.py
|
|
@@ -397,9 +397,9 @@ def _checknetloc(netloc):
|
|
# looking for characters like \u2100 that expand to 'a/c'
|
|
# IDNA uses NFKC equivalence, so normalize for this check
|
|
import unicodedata
|
|
- n = netloc.rpartition('@')[2] # ignore anything to the left of '@'
|
|
- n = n.replace(':', '') # ignore characters already included
|
|
- n = n.replace('#', '') # but not the surrounding text
|
|
+ n = netloc.replace('@', '') # ignore characters already included
|
|
+ n = n.replace(':', '') # but not the surrounding text
|
|
+ n = n.replace('#', '')
|
|
n = n.replace('?', '')
|
|
netloc2 = unicodedata.normalize('NFKC', n)
|
|
if n == netloc2:
|
|
--
|
|
2.11.0
|
|
|