Skip to content

Commit c44d58a

Browse files
committed
Issue #29142: Merge 3.5.
2 parents 19c7238 + 959ff7f commit c44d58a

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

Lib/test/test_urllib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,12 @@ def test_proxy_cgi_ignore(self):
247247
def test_proxy_bypass_environment_host_match(self):
248248
bypass = urllib.request.proxy_bypass_environment
249249
self.env.set('NO_PROXY',
250-
'localhost, anotherdomain.com, newdomain.com:1234')
250+
'localhost, anotherdomain.com, newdomain.com:1234, .d.o.t')
251251
self.assertTrue(bypass('localhost'))
252252
self.assertTrue(bypass('LocalHost')) # MixedCase
253253
self.assertTrue(bypass('LOCALHOST')) # UPPERCASE
254254
self.assertTrue(bypass('newdomain.com:1234'))
255+
self.assertTrue(bypass('foo.d.o.t')) # issue 29142
255256
self.assertTrue(bypass('anotherdomain.com:8888'))
256257
self.assertTrue(bypass('www.newdomain.com:1234'))
257258
self.assertFalse(bypass('prelocalhost'))

Lib/urllib/request.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2514,6 +2514,7 @@ def proxy_bypass_environment(host, proxies=None):
25142514
no_proxy_list = [proxy.strip() for proxy in no_proxy.split(',')]
25152515
for name in no_proxy_list:
25162516
if name:
2517+
name = name.lstrip('.') # ignore leading dots
25172518
name = re.escape(name)
25182519
pattern = r'(.+\.)?%s$' % name
25192520
if (re.match(pattern, hostonly, re.I)

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ Core and Builtins
4444
Library
4545
-------
4646

47+
- Issue #29142: In urllib.request, suffixes in no_proxy environment variable with
48+
leading dots could match related hostnames again (e.g. .b.c matches a.b.c).
49+
Patch by Milan Oberkirch.
50+
4751
- Issue #28961: Fix unittest.mock._Call helper: don't ignore the name parameter
4852
anymore. Patch written by Jiajun Huang.
4953

0 commit comments

Comments
 (0)