diff options
-rw-r--r-- | netlib/http.py | 4 | ||||
-rw-r--r-- | test/test_http.py | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/netlib/http.py b/netlib/http.py index 1b03d330..5628dd4d 100644 --- a/netlib/http.py +++ b/netlib/http.py @@ -17,7 +17,7 @@ def parse_url(url): Returns a (scheme, host, port, path) tuple, or None on error. Checks that: - port is an integer + port is an integer 0-65535 host is a valid IDNA-encoded hostname with no null-bytes path is valid ASCII """ @@ -49,6 +49,8 @@ def parse_url(url): path.decode("ascii") except ValueError: return None + if not 0 <= port <= 65535: + return None return scheme, host, port, path diff --git a/test/test_http.py b/test/test_http.py index f41a4e2d..061aeb22 100644 --- a/test/test_http.py +++ b/test/test_http.py @@ -296,6 +296,7 @@ def test_parse_url(): assert not http.parse_url("http://\xfafoo") assert not http.parse_url("http:/\xc6/localhost:56121") assert not http.parse_url("http://foo\0") + assert not http.parse_url("http://foo:999999") |