@@ -38,7 +38,14 @@ def _validate_scheme(value: str):
38
38
"""Validate scheme."""
39
39
# More schemes will be considered later.
40
40
return (
41
- value in {"ftp" , "ftps" , "git" , "http" , "https" , "rtsp" , "sftp" , "ssh" , "telnet" }
41
+ value
42
+ # fmt: off
43
+ in {
44
+ "ftp" , "ftps" , "git" , "http" , "https" ,
45
+ "rtmp" , "rtmps" , "rtsp" , "sftp" ,
46
+ "ssh" , "telnet" ,
47
+ }
48
+ # fmt: on
42
49
if value
43
50
else False
44
51
)
@@ -112,8 +119,18 @@ def _validate_optionals(path: str, query: str, fragment: str, strict_query: bool
112
119
optional_segments = True
113
120
if path :
114
121
optional_segments &= bool (_path_regex ().match (path ))
115
- if query and parse_qs (query , strict_parsing = strict_query ):
116
- optional_segments &= True
122
+ try :
123
+ if (
124
+ query
125
+ # ref: https://github.com/python/cpython/issues/117109
126
+ and parse_qs (query , strict_parsing = strict_query , separator = "&" )
127
+ and parse_qs (query , strict_parsing = strict_query , separator = ";" )
128
+ ):
129
+ optional_segments &= True
130
+ except TypeError :
131
+ # for Python < v3.9.2 (official v3.10)
132
+ if query and parse_qs (query , strict_parsing = strict_query ):
133
+ optional_segments &= True
117
134
if fragment :
118
135
# See RFC3986 Section 3.5 Fragment for allowed characters
119
136
optional_segments &= bool (re .fullmatch (r"[0-9a-zA-Z?/:@\-._~%!$&'()*+,;=]*" , fragment ))
0 commit comments