Skip to content

Commit 0f0cc9b

Browse files
gh-137146: Add tests on IPvFuture
1 parent 9864ce1 commit 0f0cc9b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Lib/test/test_urlparse.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import unittest
44
import urllib.parse
55
from test import support
6+
from strings import ascii_letters, digits
67

78
RFC1808_BASE = "http://a/b/c/d;p?q#f"
89
RFC2396_BASE = "http://a/b/c/d;p?q"
@@ -1419,6 +1420,17 @@ def test_invalid_bracketed_hosts(self):
14191420
self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://prefix]v6a.ip[suffix')
14201421
self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://prefix]v6a.ip')
14211422
self.assertRaises(ValueError, urllib.parse.urlsplit, 'scheme://v6a.ip[suffix')
1423+
# unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
1424+
unreserved = ascii_letters + digits + "-" + "." + "_" + "~"
1425+
# sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
1426+
sub_delims = "!" + "$" + "&" + "'" + "(" + ")" + "*" + "+" + "," + ";" + "="
1427+
ipvfuture_authorized_characters = unreserved + sub_delims + ":"
1428+
removed_characters = "\t\n\r"
1429+
for character in range(256):
1430+
character = chr(character)
1431+
if character in ipvfuture_authorized_characters or character in removed_characters:
1432+
continue
1433+
self.assertRaises(ValueError, urllib.parse.urlsplit, f'scheme://[v7.invalid{character}invalid]/')
14221434

14231435
def test_splitting_bracketed_hosts(self):
14241436
p1 = urllib.parse.urlsplit('scheme://user@[v6a.ip]:1234/path?query')

0 commit comments

Comments
 (0)