forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pythongh-105704: Disallow IPv6 URLs with invalid prefix/suffix
- Loading branch information
Showing
2 changed files
with
30 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -1322,16 +1322,29 @@ def test_issue14072(self): | |
self.assertEqual(p2.path, '+31641044153') | ||
|
||
def test_invalid_bracketed_hosts(self): | ||
self.assertRaises(ValueError, urllib.parse.urlsplit, 'Scheme://user@[192.0.2.146]/Path?Query') | ||
self.assertRaises(ValueError, urllib.parse.urlsplit, 'Scheme://user@[important.com:8000]/Path?Query') | ||
self.assertRaises(ValueError, urllib.parse.urlsplit, 'Scheme://user@[v123r.IP]/Path?Query') | ||
self.assertRaises(ValueError, urllib.parse.urlsplit, 'Scheme://user@[v12ae]/Path?Query') | ||
self.assertRaises(ValueError, urllib.parse.urlsplit, 'Scheme://user@[v.IP]/Path?Query') | ||
self.assertRaises(ValueError, urllib.parse.urlsplit, 'Scheme://user@[v123.]/Path?Query') | ||
self.assertRaises(ValueError, urllib.parse.urlsplit, 'Scheme://user@[v]/Path?Query') | ||
self.assertRaises(ValueError, urllib.parse.urlsplit, 'Scheme://user@[0439:23af::2309::fae7:1234]/Path?Query') | ||
self.assertRaises(ValueError, urllib.parse.urlsplit, 'Scheme://user@[0439:23af:2309::fae7:1234:2342:438e:192.0.2.146]/Path?Query') | ||
self.assertRaises(ValueError, urllib.parse.urlsplit, 'Scheme://user@]v6a.ip[/Path') | ||
cases = [ | ||
'Scheme://user@[192.0.2.146]/Path?Query', | ||
'Scheme://user@[important.com:8000]/Path?Query', | ||
'Scheme://user@[v123r.IP]/Path?Query', | ||
'Scheme://user@[v12ae]/Path?Query', | ||
'Scheme://user@[v.IP]/Path?Query', | ||
'Scheme://user@[v123.]/Path?Query', | ||
'Scheme://user@[v]/Path?Query', | ||
'Scheme://user@[0439:23af::2309::fae7:1234]/Path?Query', | ||
'Scheme://user@[0439:23af:2309::fae7:1234:2342:438e:192.0.2.146]/Path?Query', | ||
'Scheme://user@]v6a.ip[/Path', | ||
'Scheme://user@[v6a.ip/path?query', | ||
'Scheme://[email protected]]/path?query', | ||
'Scheme://user@prefix.[v6a.ip]/path?query', | ||
'Scheme://user@[v6a.ip].suffix/path?query', | ||
] | ||
|
||
for case in cases: | ||
with self.subTest(case=case): | ||
with self.assertRaises(ValueError): | ||
urllib.parse.urlsplit(case).hostname | ||
with self.assertRaises(ValueError): | ||
urllib.parse.urlparse(case).hostname | ||
|
||
def test_splitting_bracketed_hosts(self): | ||
p1 = urllib.parse.urlsplit('scheme://user@[v6a.ip]/path?query') | ||
|
This file contains 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