Skip to content

Commit 56ac545

Browse files
authored
Update cookiejar.py
1 parent af9d29e commit 56ac545

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Lib/http/cookiejar.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,15 @@ def eff_request_host(request):
648648
649649
"""
650650
erhn = req_host = request_host(request)
651-
is_IPV6 = req_host.startswith('[') and req_host.endswith(']')
651+
if req_host.startswith('[') and req_host.endswith(']'):
652+
from ipaddress import IPv6Address
653+
try:
654+
IPv6Address(req_host.removeprefix('[').removesuffix(']'))
655+
is_IPV6 = True
656+
except ValueError:
657+
is_IPV6 = False
658+
else:
659+
is_IPV6 = False
652660
if "." not in req_host and not is_IPV6:
653661
# avoid adding .local at the end of a IPV6 address
654662
erhn = req_host + ".local"

0 commit comments

Comments
 (0)