Skip to content

Commit d197796

Browse files
authored
prevent to remove the debug message
1 parent b7d6e4e commit d197796

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Lib/http/cookiejar.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,12 @@ def request_port(request):
660660
if match:
661661
port = match[0].removeprefix(':')
662662
else:
663+
i = request.host.rfind(':')
664+
if (i >= 0
665+
and not ']' in request.host[i+1:]): # to prevent IPv6 addresses
666+
_debug("nonnumeric port: '%s'", request.host[i+1:])
663667
port = DEFAULT_HTTP_PORT
664668
return port
665-
666669
# Characters in addition to A-Z, a-z, 0-9, '_', '.', and '-' that don't
667670
# need to be escaped to form a valid HTTP URL (RFCs 2396 and 1738).
668671
HTTP_PATH_SAFE = "%/;:@&=+$,!~*'()"

0 commit comments

Comments
 (0)