]> granicus.if.org Git - python/commitdiff
Fix closes issue12698 - make the no_proxy environment variable handling a bit lenient...
authorSenthil Kumaran <senthil@uthcode.com>
Sat, 6 Aug 2011 04:24:33 +0000 (12:24 +0800)
committerSenthil Kumaran <senthil@uthcode.com>
Sat, 6 Aug 2011 04:24:33 +0000 (12:24 +0800)
Lib/test/test_urllib.py
Lib/urllib.py

index e7e54a2dd89d178045b11ba84f26e4e455ce5ef5..401dd5ca0cbc97181bbd50e7cfc9151437d40b9b 100644 (file)
@@ -114,6 +114,9 @@ class ProxyTests(unittest.TestCase):
         proxies = urllib.getproxies_environment()
         # getproxies_environment use lowered case truncated (no '_proxy') keys
         self.assertEqual('localhost', proxies['no'])
+        # List of no_proxies with space.
+        self.env.set('NO_PROXY', 'localhost, anotherdomain.com, newdomain.com')
+        self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com'))
 
 
 class urlopen_HttpTests(unittest.TestCase):
index aac235da2c541f82eb65b1fc8196e7c044208efb..1261ec14a176660184e25e140762ced5198d9eec 100644 (file)
@@ -1366,7 +1366,8 @@ def proxy_bypass_environment(host):
     # strip port off host
     hostonly, port = splitport(host)
     # check if the host ends with any of the DNS suffixes
-    for name in no_proxy.split(','):
+    no_proxy_list = [proxy.strip() for proxy in no_proxy.split(',')]
+    for name in no_proxy_list:
         if name and (hostonly.endswith(name) or host.endswith(name)):
             return 1
     # otherwise, don't bypass