Bug report
Prerequisites
- Windows operating system
- A proxy server is used.
- The trustlist of the proxy service contains '[*'.
Use the following code to request an IPv6 address such as https://[fa::01]:80/,the following error occurs:
re.error: unterminated character set at position 0
req = request.Request(url=url, method=method, headers=headers, data=data)
resp = request.urlopen(req, timeout=timeout, context=ctx)
I noticed that the problem comes from the proxy_bypass_registry method in urllib/request.py, which reads the system's proxy configuration and checks whether the host needs a proxy, but the regular expression [* works fine on windows, but fails to verify in python. I thought about configuring *] on windows, but this won't save, so I'm guessing there's a difference in the regular expression implementation between the two systems.
So can we add an escape processing in the code and replace [ with \[?
Your environment
- CPython versions tested on: Python 3.9.13
- Operating system and architecture: Windows 10
Bug report
Prerequisites
Use the following code to request an IPv6 address such as https://[fa::01]:80/,the following error occurs:
re.error: unterminated character set at position 0
I noticed that the problem comes from the proxy_bypass_registry method in urllib/request.py, which reads the system's proxy configuration and checks whether the host needs a proxy, but the regular expression
[*works fine on windows, but fails to verify in python. I thought about configuring*]on windows, but this won't save, so I'm guessing there's a difference in the regular expression implementation between the two systems.So can we add an escape processing in the code and replace
[with\[?Your environment