Skip to content

bpo-42627: Fix wrong parsing of Windows registry proxy settings #26307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8ca4f5a
bpo-42627: Fix wrong parsing of Windows registry proxy settings
CrazyBoyFeng May 21, 2021
5b7d88c
📜🤖 Added by blurb_it.
blurb-it[bot] May 22, 2021
dc2e781
Remove support for multi proxy per one protocol
CrazyBoyFeng May 28, 2021
2edd42a
Merge branch 'python:main' into fix-issue-42627
CrazyBoyFeng May 29, 2021
33f07b2
Use SOCKS proxy for HTTP(S) protocols
CrazyBoyFeng Jun 8, 2021
37fd713
Fix `ValueError`
CrazyBoyFeng Jun 8, 2021
116e7eb
Merge branch 'python:main' into fix-issue-42627
CrazyBoyFeng Jul 2, 2021
793fead
Merge branch 'python:main' into fix-issue-42627
CrazyBoyFeng Aug 19, 2021
e74efd8
Fix `ValueError`
CrazyBoyFeng Sep 8, 2021
3e4cd4b
Merge branch 'python:main' into fix-issue-42627
CrazyBoyFeng Sep 17, 2021
cf3ca0c
Merge branch 'python:main' into fix-issue-42627
CrazyBoyFeng Sep 17, 2021
e12cfa5
Merge branch 'python:main' into fix-issue-42627
CrazyBoyFeng Sep 28, 2021
b955bf3
Merge branch 'python:main' into fix-issue-42627
CrazyBoyFeng Oct 17, 2021
223670e
Merge branch 'python:main' into fix-issue-42627
CrazyBoyFeng Oct 24, 2021
6602d47
Merge branch 'python:main' into fix-issue-42627
CrazyBoyFeng Nov 1, 2021
1622ca8
Merge branch 'python:main' into fix-issue-42627
CrazyBoyFeng Nov 19, 2021
fad75ed
Merge branch 'python:main' into fix-issue-42627
CrazyBoyFeng Dec 14, 2021
510b478
Merge branch 'python:main' into fix-issue-42627
CrazyBoyFeng Jan 7, 2022
95f9c40
Merge branch 'python:main' into fix-issue-42627
CrazyBoyFeng Mar 8, 2022
122ccf3
Merge branch 'main' into fix-issue-42627
zooba Apr 28, 2022
e0367b0
Update Misc/NEWS.d/next/Library/2021-05-22-07-58-59.bpo-42627.EejtD0.rst
zooba May 10, 2022
4faf529
Update 2021-05-22-07-58-59.bpo-42627.EejtD0.rst
CrazyBoyFeng May 11, 2022
783deb9
Update 2021-05-22-07-58-59.bpo-42627.EejtD0.rst
CrazyBoyFeng May 11, 2022
f476457
Merge branch 'main' into fix-issue-42627
CrazyBoyFeng May 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions Lib/urllib/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -2679,22 +2679,26 @@ def getproxies_registry():
# Returned as Unicode but problems if not converted to ASCII
proxyServer = str(winreg.QueryValueEx(internetSettings,
'ProxyServer')[0])
if '=' in proxyServer:
# Per-protocol settings
for p in proxyServer.split(';'):
protocol, address = p.split('=', 1)
# See if address has a type:// prefix
if not re.match('(?:[^/:]+)://', address):
address = '%s://%s' % (protocol, address)
proxies[protocol] = address
else:
# Use one setting for all protocols
if proxyServer[:5] == 'http:':
proxies['http'] = proxyServer
else:
proxies['http'] = 'http://%s' % proxyServer
proxies['https'] = 'https://%s' % proxyServer
proxies['ftp'] = 'ftp://%s' % proxyServer
if '=' not in proxyServer and ';' not in proxyServer:
# Use one setting for all protocols.
proxyServer = 'http={0};https={0};ftp={0}'.format(proxyServer)
for p in proxyServer.split(';'):
protocol, address = p.split('=', 1)
# See if address has a type:// prefix
if not re.match('(?:[^/:]+)://', address):
# Add type:// prefix to address without specifying type
if protocol in ('http', 'https', 'ftp'):
# The default proxy type of Windows is HTTP
address = 'http://' + address
elif protocol == 'socks':
address = 'socks://' + address
proxies[protocol] = address
# Use SOCKS proxy for HTTP(S) protocols
if proxies.get('socks'):
# The default SOCKS proxy type of Windows is SOCKS4
address = re.sub(r'^socks://', 'socks4://', proxies['socks'])
proxies['http'] = proxies.get('http') or address
proxies['https'] = proxies.get('https') or address
internetSettings.Close()
except (OSError, ValueError, TypeError):
# Either registry key not found etc, or the value in an
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix incorrect parsing of Windows registry proxy settings