Skip to content
Permalink
Browse files

bpo-36742: Corrects fix to handle decomposition in usernames (GH-13812)

(cherry picked from commit 8d0ef0b)

Co-authored-by: Steve Dower <steve.dower@python.org>
  • Loading branch information...
miss-islington and zooba committed Jun 4, 2019
1 parent 12c1787 commit 250b62acc59921d399f0db47db3b462cd6037e09
Showing with 9 additions and 8 deletions.
  1. +6 −5 Lib/test/test_urlparse.py
  2. +3 −3 Lib/urllib/parse.py
@@ -1008,11 +1008,12 @@ def test_urlsplit_normalization(self):
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."""
@@ -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:

0 comments on commit 250b62a

Please sign in to comment.
You can’t perform that action at this time.