Skip to content

Commit 04c15d5

Browse files
committed
Issue #29142: Merge 3.6.
2 parents 9d60b94 + c44d58a commit 04c15d5

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
@@ -2513,6 +2513,7 @@ def proxy_bypass_environment(host, proxies=None):
25132513
no_proxy_list = [proxy.strip() for proxy in no_proxy.split(',')]
25142514
for name in no_proxy_list:
25152515
if name:
2516+
name = name.lstrip('.') # ignore leading dots
25162517
name = re.escape(name)
25172518
pattern = r'(.+\.)?%s$' % name
25182519
if (re.match(pattern, hostonly, re.I)

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ Core and Builtins
212212
Library
213213
-------
214214

215+
- Issue #29142: In urllib.request, suffixes in no_proxy environment variable with
216+
leading dots could match related hostnames again (e.g. .b.c matches a.b.c).
217+
Patch by Milan Oberkirch.
218+
215219
- Issue #28961: Fix unittest.mock._Call helper: don't ignore the name parameter
216220
anymore. Patch written by Jiajun Huang.
217221

0 commit comments

Comments
 (0)