bpo-36742: Corrects fix to handle decomposition in usernames (#13812)
This commit is contained in:
parent
800d786370
commit
8d0ef0b5ed
|
@ -1018,11 +1018,12 @@ class UrlParseTestCase(unittest.TestCase):
|
||||||
urllib.parse.urlsplit('http://\u30d5\u309a\ufe1380')
|
urllib.parse.urlsplit('http://\u30d5\u309a\ufe1380')
|
||||||
|
|
||||||
for scheme in ["http", "https", "ftp"]:
|
for scheme in ["http", "https", "ftp"]:
|
||||||
for c in denorm_chars:
|
for netloc in ["netloc{}false.netloc", "n{}user@netloc"]:
|
||||||
url = "{}://netloc{}false.netloc/path".format(scheme, c)
|
for c in denorm_chars:
|
||||||
with self.subTest(url=url, char='{:04X}'.format(ord(c))):
|
url = "{}://{}/path".format(scheme, netloc.format(c))
|
||||||
with self.assertRaises(ValueError):
|
with self.subTest(url=url, char='{:04X}'.format(ord(c))):
|
||||||
urllib.parse.urlsplit(url)
|
with self.assertRaises(ValueError):
|
||||||
|
urllib.parse.urlsplit(url)
|
||||||
|
|
||||||
class Utility_Tests(unittest.TestCase):
|
class Utility_Tests(unittest.TestCase):
|
||||||
"""Testcase to test the various utility functions in the urllib."""
|
"""Testcase to test the various utility functions in the urllib."""
|
||||||
|
|
|
@ -402,9 +402,9 @@ def _checknetloc(netloc):
|
||||||
# looking for characters like \u2100 that expand to 'a/c'
|
# looking for characters like \u2100 that expand to 'a/c'
|
||||||
# IDNA uses NFKC equivalence, so normalize for this check
|
# IDNA uses NFKC equivalence, so normalize for this check
|
||||||
import unicodedata
|
import unicodedata
|
||||||
n = netloc.rpartition('@')[2] # ignore anything to the left of '@'
|
n = netloc.replace('@', '') # ignore characters already included
|
||||||
n = n.replace(':', '') # ignore characters already included
|
n = n.replace(':', '') # but not the surrounding text
|
||||||
n = n.replace('#', '') # but not the surrounding text
|
n = n.replace('#', '')
|
||||||
n = n.replace('?', '')
|
n = n.replace('?', '')
|
||||||
netloc2 = unicodedata.normalize('NFKC', n)
|
netloc2 = unicodedata.normalize('NFKC', n)
|
||||||
if n == netloc2:
|
if n == netloc2:
|
||||||
|
|
Loading…
Reference in New Issue