Skip to content

Commit 0e2684d

Browse files
gh-137146: Fix unicode characters in IPv6 Zone ID
1 parent e33f050 commit 0e2684d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Lib/urllib/parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ def _check_bracketed_host(hostname):
466466
ip = ipaddress.ip_address(hostname) # Throws Value Error if not IPv6 or IPv4
467467
if isinstance(ip, ipaddress.IPv4Address):
468468
raise ValueError(f"An IPv4 address cannot be in brackets")
469-
if "%" in hostname and not re.match(r"\A(%[a-fA-F0-9]{2}|[\w\.~-])+\z", hostname.split("%", 1)[1]):
469+
if "%" in hostname and not re.match(r"\A(%[a-fA-F0-9]{2}|[\w\.~-])+\z", hostname.split("%", 1)[1], flags=re.ASCII):
470470
raise ValueError(f"IPv6 ZoneID is invalid")
471471

472472
# typed=True avoids BytesWarnings being emitted during cache key

0 commit comments

Comments
 (0)