Skip to content

Commit cdda526

Browse files
authored
Add stricter check for IPv6 case
1 parent 7e3237a commit cdda526

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Lib/http/cookiejar.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,8 @@ def request_port(request):
662662
else:
663663
i = request.host.rfind(':')
664664
if (i >= 0
665-
and not ']' in request.host[i+1:]): # to prevent IPv6 addresses
665+
and not ']' in request.host[i+1:]
666+
and not request.host.startswith('[')): # to prevent IPv6 addresses
666667
_debug("nonnumeric port: '%s'", request.host[i+1:])
667668
port = DEFAULT_HTTP_PORT
668669
return port

0 commit comments

Comments
 (0)