mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
Merge pull request #2232 from r1b/master
fixes ipv6 authority form parsing in CONNECT
This commit is contained in:
commit
c7b5012752
@ -271,7 +271,9 @@ def _parse_authority_form(hostport):
|
|||||||
ValueError, if the input is malformed
|
ValueError, if the input is malformed
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
host, port = hostport.split(b":")
|
host, port = hostport.rsplit(b":", 1)
|
||||||
|
if host.startswith(b"[") and host.endswith(b"]"):
|
||||||
|
host = host[1:-1]
|
||||||
port = int(port)
|
port = int(port)
|
||||||
if not check.is_valid_host(host) or not check.is_valid_port(port):
|
if not check.is_valid_host(host) or not check.is_valid_port(port):
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
|
@ -243,6 +243,7 @@ def test_read_request_line():
|
|||||||
|
|
||||||
def test_parse_authority_form():
|
def test_parse_authority_form():
|
||||||
assert _parse_authority_form(b"foo:42") == (b"foo", 42)
|
assert _parse_authority_form(b"foo:42") == (b"foo", 42)
|
||||||
|
assert _parse_authority_form(b"[2001:db8:42::]:443") == (b"2001:db8:42::", 443)
|
||||||
with pytest.raises(exceptions.HttpSyntaxException):
|
with pytest.raises(exceptions.HttpSyntaxException):
|
||||||
_parse_authority_form(b"foo")
|
_parse_authority_form(b"foo")
|
||||||
with pytest.raises(exceptions.HttpSyntaxException):
|
with pytest.raises(exceptions.HttpSyntaxException):
|
||||||
|
Loading…
Reference in New Issue
Block a user