Merge branch 'master' into limit-supported-codecs

This commit is contained in:
Tom Christie 2023-10-19 10:48:56 +01:00 committed by GitHub
commit b506c849c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -87,7 +87,7 @@ COMPONENT_REGEX = {
# We use these simple regexs as a first pass before handing off to
# the stdlib 'ipaddress' module for IP address validation.
IPv4_STYLE_HOSTNAME = re.compile(r"^[0-9]+.[0-9]+.[0-9]+.[0-9]+$")
IPv4_STYLE_HOSTNAME = re.compile(r"^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$")
IPv6_STYLE_HOSTNAME = re.compile(r"^\[.*\]$")

View File

@ -45,6 +45,12 @@ def test_urlparse_normalized_host():
assert url.host == "example.com"
def test_urlparse_ipv4_like_host():
"""rare host names used to quality as IPv4"""
url = httpx.URL("https://023b76x43144/")
assert url.host == "023b76x43144"
def test_urlparse_valid_ipv4():
url = httpx.URL("https://1.2.3.4/")
assert url.host == "1.2.3.4"