mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-01-31 07:18:58 +00:00
Check that hosts in parse_url do not contain NULL bytes.
This commit is contained in:
parent
2897ddfbee
commit
cd4ed8530f
@ -18,7 +18,7 @@ def parse_url(url):
|
||||
|
||||
Checks that:
|
||||
port is an integer
|
||||
host is a valid IDNA-encoded hostname
|
||||
host is a valid IDNA-encoded hostname with no null-bytes
|
||||
path is valid ASCII
|
||||
"""
|
||||
scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
|
||||
@ -43,6 +43,8 @@ def parse_url(url):
|
||||
host.decode("idna")
|
||||
except ValueError:
|
||||
return None
|
||||
if "\0" in host:
|
||||
return None
|
||||
try:
|
||||
path.decode("ascii")
|
||||
except ValueError:
|
||||
|
@ -294,8 +294,9 @@ def test_parse_url():
|
||||
|
||||
# Invalid IDNA
|
||||
assert not http.parse_url("http://\xfafoo")
|
||||
|
||||
assert not http.parse_url("http:/\xc6/localhost:56121")
|
||||
assert not http.parse_url("http://foo\0")
|
||||
|
||||
|
||||
|
||||
def test_parse_http_basic_auth():
|
||||
|
Loading…
Reference in New Issue
Block a user