[New-bugs-announce] [issue32465] [urllib] proxy_bypass_registry - extra error handling required for ProxyOverride, Windows under proxy environment

chansol kim report at bugs.python.org
Sun Dec 31 09:01:24 EST 2017


New submission from chansol kim <chansoli at gmail.com>:

[Problem]
- String value from registry Proxy override is read and incorrectly decides the current connection requires not to use proxy.

[Setup]
- Using urllib under proxy environment.
- Proxy bypass settings are in place. ProxyOverride string value in registry ends with ;

[Detail]
https://github.com/python/cpython/blob/2.7/Lib/urllib.py
proxy_bypass_registry has an issue
1. It gets registry value from HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings ProxyEnable string value.
2. Splits the string with ;. And as the registry value ends with ; the split list contains a zero length string at the end.
3. Use the split string to re.match. And as there is zero length string at the end it, and the result of re.match('', 'anystring', re.I) is always not None.
4. Afterwards connection is attempted without using the proxy, hence connection cannot be made

>From line 1617

        proxyOverride = proxyOverride.split(';')
        # now check if we match one of the registry values.
        for test in proxyOverride:
            if test == '<local>':
                if '.' not in rawHost:
                    return 1
            test = test.replace(".", r"\.")     # mask dots
            test = test.replace("*", r".*")     # change glob sequence
            test = test.replace("?", r".")      # change glob char
            for val in host:
                # print "%s <--> %s" %( test, val )
                if re.match(test, val, re.I):
                    return 1

----------
components: Library (Lib)
messages: 309284
nosy: chansol kim
priority: normal
severity: normal
status: open
title: [urllib] proxy_bypass_registry - extra error handling required for ProxyOverride, Windows under proxy environment
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32465>
_______________________________________


More information about the New-bugs-announce mailing list