@@ -2679,22 +2679,26 @@ def getproxies_registry():
26792679 # Returned as Unicode but problems if not converted to ASCII
26802680 proxyServer = str (winreg .QueryValueEx (internetSettings ,
26812681 'ProxyServer' )[0 ])
2682- if '=' in proxyServer :
2683- # Per-protocol settings
2684- for p in proxyServer .split (';' ):
2685- protocol , address = p .split ('=' , 1 )
2686- # See if address has a type:// prefix
2687- if not re .match ('(?:[^/:]+)://' , address ):
2688- address = '%s://%s' % (protocol , address )
2689- proxies [protocol ] = address
2690- else :
2691- # Use one setting for all protocols
2692- if proxyServer [:5 ] == 'http:' :
2693- proxies ['http' ] = proxyServer
2694- else :
2695- proxies ['http' ] = 'http://%s' % proxyServer
2696- proxies ['https' ] = 'https://%s' % proxyServer
2697- proxies ['ftp' ] = 'ftp://%s' % proxyServer
2682+ if '=' not in proxyServer and ';' not in proxyServer :
2683+ # Use one setting for all protocols.
2684+ proxyServer = 'http={0};https={0};ftp={0}' .format (proxyServer )
2685+ for p in proxyServer .split (';' ):
2686+ protocol , address = p .split ('=' , 1 )
2687+ # See if address has a type:// prefix
2688+ if not re .match ('(?:[^/:]+)://' , address ):
2689+ # Add type:// prefix to address without specifying type
2690+ if protocol in ('http' , 'https' , 'ftp' ):
2691+ # The default proxy type of Windows is HTTP
2692+ address = 'http://' + address
2693+ elif protocol == 'socks' :
2694+ address = 'socks://' + address
2695+ proxies [protocol ] = address
2696+ # Use SOCKS proxy for HTTP(S) protocols
2697+ if proxies .get ('socks' ):
2698+ # The default SOCKS proxy type of Windows is SOCKS4
2699+ address = re .sub (r'^socks://' , 'socks4://' , proxies ['socks' ])
2700+ proxies ['http' ] = proxies .get ('http' ) or address
2701+ proxies ['https' ] = proxies .get ('https' ) or address
26982702 internetSettings .Close ()
26992703 except (OSError , ValueError , TypeError ):
27002704 # Either registry key not found etc, or the value in an
0 commit comments