]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-36742: Corrects fix to handle decomposition in usernames (#13812)
authorSteve Dower <steve.dower@python.org>
Tue, 4 Jun 2019 15:55:30 +0000 (08:55 -0700)
committerŁukasz Langa <lukasz@langa.pl>
Tue, 4 Jun 2019 15:55:29 +0000 (17:55 +0200)
Lib/test/test_urlparse.py
Lib/urllib/parse.py

index 43447656376472ba95d5f75ffd7bd1a2465d5e1a..4ae6ed33858ce225bcf6c9d133e6de08859ec831 100644 (file)
@@ -1018,11 +1018,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."""
index daefb2025b14ea8666f945f982c1dc6c60439a8c..b6608783a894712125c3788338758292a1a0e22b 100644 (file)
@@ -402,9 +402,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: