]> granicus.if.org Git - python/commitdiff
bpo-36742: Corrects fix to handle decomposition in usernames (GH-13812) (GH-13814...
authorVictor Stinner <vstinner@redhat.com>
Sat, 7 Sep 2019 06:33:24 +0000 (08:33 +0200)
committerlarryhastings <larry@hastings.org>
Sat, 7 Sep 2019 06:33:24 +0000 (07:33 +0100)
(cherry picked from commit 8d0ef0b5edeae52960c7ed05ae8a12388324f87e)

Co-authored-by: Steve Dower <steve.dower@python.org>
(cherry picked from commit fd1771dbdd28709716bd531580c40ae5ed814468)

Lib/test/test_urlparse.py
Lib/urllib/parse.py

index 1e90e18609b2f9c1a7161d8782dd2ba79fbfbe7a..ebb30ea01c760e17614c14e77713c106995b4043 100644 (file)
@@ -994,11 +994,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 7405d660fc4e26c464b08e3003eb84d5890a6038..60fd5e4e0f3f1281cee3d189cc7c94a7ca7e6279 100644 (file)
@@ -333,9 +333,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: