FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-105708: 'V' could be case insensitive for IPvFuture hostnames by csreddy98 · Pull Request #105709 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
15 changes: 10 additions & 5 deletions Lib/test/test_urlparse.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1653,15 +1653,20 @@ def test_splitting_bracketed_hosts(self):
self.assertEqual(p1.username, 'user')
self.assertEqual(p1.path, '/path')
self.assertEqual(p1.port, 1234)
p2 = urllib.parse.urlsplit('scheme://user@[0439:23af:2309::fae7%test]/path?query')
self.assertEqual(p2.hostname, '0439:23af:2309::fae7%test')
p2 = urllib.parse.urlsplit('scheme://user@[V6a.ip]:1234/path?query')
Comment thread
orsenthil marked this conversation as resolved.
self.assertEqual(p2.hostname, 'v6a.ip')
self.assertEqual(p2.username, 'user')
self.assertEqual(p2.path, '/path')
self.assertIs(p2.port, None)
p3 = urllib.parse.urlsplit('scheme://user@[0439:23af:2309::fae7:1234:192.0.2.146%test]/path?query')
self.assertEqual(p3.hostname, '0439:23af:2309::fae7:1234:192.0.2.146%test')
self.assertEqual(p2.port, 1234)
p3 = urllib.parse.urlsplit('scheme://user@[0439:23af:2309::fae7%test]/path?query')
self.assertEqual(p3.hostname, '0439:23af:2309::fae7%test')
self.assertEqual(p3.username, 'user')
self.assertEqual(p3.path, '/path')
self.assertIs(p3.port, None)
p4 = urllib.parse.urlsplit('scheme://user@[0439:23af:2309::fae7:1234:192.0.2.146%test]/path?query')
self.assertEqual(p4.hostname, '0439:23af:2309::fae7:1234:192.0.2.146%test')
self.assertEqual(p4.username, 'user')
self.assertEqual(p4.path, '/path')

def test_port_casting_failure_message(self):
message = "Port could not be cast to integer value as 'oracle'"
Expand Down
4 changes: 2 additions & 2 deletions Lib/urllib/parse.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,8 @@ def _check_bracketed_netloc(netloc):
# Valid bracketed hosts are defined in
# https://www.rfc-editor.org/rfc/rfc3986#page-49 and https://url.spec.whatwg.org/
def _check_bracketed_host(hostname):
if hostname.startswith('v'):
if not re.match(r"\Av[a-fA-F0-9]+\..+\z", hostname):
if hostname.startswith(('v', 'V')):
if not re.match(r"\A[vV][a-fA-F0-9]+\..+\z", hostname):
raise ValueError(f"IPvFuture address is invalid")
else:
ip = ipaddress.ip_address(hostname) # Throws Value Error if not IPv6 or IPv4
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Accept an uppercase V prefix in IPvFuture addresses in :func:`urllib.parse.urlsplit`.
Loading

Back | FazBrowse Home | New Git URL