8000 gh-102153: Start stripping C0 control and space chars in `urlsplit` by illia-v · Pull Request #102508 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-102153: Start stripping C0 control and space chars in urlsplit #102508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 17, 2023
Merged
Prev Previous commit
Next Next commit
Fix the unittests to allow trailing C0
Also be explicit about specifying utf-8 on encode and decode.
  • Loading branch information
gpshead committed May 2, 2023
commit fd3e429a1c69b9a3141d5668ff9f110cc6f97035
8 changes: 4 additions & 4 deletions Lib/test/test_urlparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def test_urlsplit_strip_url(self):
noise = bytes(range(0, 0x20 + 1))
base_url = "http://User:Pass@www.python.org:080/doc/?query=yes#frag"

url = noise.decode() + base_url + noise.decode()
url = noise.decode("utf-8") + base_url
p = urllib.parse.urlsplit(url)
self.assertEqual(p.scheme, "http")
self.assertEqual(p.netloc, "User:Pass@www.python.org:080")
Expand All @@ -666,7 +666,7 @@ def test_urlsplit_strip_url(self):
self.assertEqual(p.port, 80)
self.assertEqual(p.geturl(), base_url)

url = noise + base_url.encode() + noise
url = noise + base_url.encode("utf-8")
p = urllib.parse.urlsplit(url)
self.assertEqual(p.scheme, b"http")
self.assertEqual(p.netloc, b"User:Pass@www.python.org:080")
Expand All @@ -677,7 +677,7 @@ def test_urlsplit_strip_url(self):
self.assertEqual(p.password, b"Pass")
self.assertEqual(p.hostname, b"www.python.org")
self.assertEqual(p.port, 80)
self.assertEqual(p.geturl(), base_url.encode())
self.assertEqual(p.geturl(), base_url.encode("utf-8"))

# Test that trailing space is preserved as some applications rely on
# this within query strings.
Expand All @@ -702,7 +702,7 @@ def test_urlsplit_strip_url(self):

# with scheme as cache-key
url = "//www.python.org/"
scheme = noise.decode() + "https" + noise.decode()
scheme = noise.decode("utf-8") + "https" + noise.decode("utf-8")
for _ in range(2):
p = urllib.parse.urlsplit(url, scheme=scheme)
self.assertEqual(p.scheme, "https")
Expand Down
0