From bb9a5cfa3dbd1a43d4c80eb1d0d7adba05b1ef25 Mon Sep 17 00:00:00 2001 From: Christian van Rensen Date: Thu, 28 Jul 2022 18:29:19 +0200 Subject: [PATCH 1/2] fix a false-negative test * no_proxy is meant to operate on the destination address, not on the name of the proxy * if both end with `'.example'`, the test does not nail down the behaviour --- test/net/http/test_http.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index e9471273..0057dd3b 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -126,10 +126,10 @@ def test_proxy_address def test_proxy_address_no_proxy TestNetHTTPUtils.clean_http_proxy_env do - http = Net::HTTP.new 'hostname.example', nil, 'proxy.example', nil, nil, nil, 'example' + http = Net::HTTP.new 'hostname.example', nil, 'proxy.com', nil, nil, nil, 'example' assert_nil http.proxy_address - http = Net::HTTP.new '10.224.1.1', nil, 'proxy.example', nil, nil, nil, 'example,10.224.0.0/22' + http = Net::HTTP.new '10.224.1.1', nil, 'proxy.com', nil, nil, nil, 'example,10.224.0.0/22' assert_nil http.proxy_address end end From f4951dc42a3b7e3fddc9f87cc4a2d6a412453f64 Mon Sep 17 00:00:00 2001 From: Christian van Rensen Date: Thu, 28 Jul 2022 18:30:01 +0200 Subject: [PATCH 2/2] fix no_proxy behaviour --- lib/net/http.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/net/http.rb b/lib/net/http.rb index a5834412..d8863dfb 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -664,7 +664,7 @@ def HTTP.new(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_p elsif p_addr == :ENV then http.proxy_from_env = true else - if p_addr && p_no_proxy && !URI::Generic.use_proxy?(p_addr, p_addr, p_port, p_no_proxy) + if p_addr && p_no_proxy && !URI::Generic.use_proxy?(address, address, port, p_no_proxy) p_addr = nil p_port = nil end