diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-01-17 12:54:35 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-01-17 12:54:35 +0000 |
commit | 556e3da4216c926e71dea9ce4ea4a08dcfdc1275 (patch) | |
tree | 987d473b21eb1e006708d439a86b441974d7ef2f /test/uri | |
parent | 2a9dd6b81888433dbcbc466aefcad7e197880439 (diff) | |
download | bundler-556e3da4216c926e71dea9ce4ea4a08dcfdc1275.tar.gz |
uri/generic.rb: fix exception on non-IP format
* lib/uri/generic.rb (URI::Generic#find_proxy): match IP address
no_proxy against resolved self IP address. [Fix GH-1513]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/uri')
-rw-r--r-- | test/uri/test_generic.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb index b226b2278b..1a470a6d18 100644 --- a/test/uri/test_generic.rb +++ b/test/uri/test_generic.rb @@ -839,6 +839,31 @@ class URI::TestGeneric < Test::Unit::TestCase with_proxy_env('http_proxy'=>'http://127.0.0.1:8080', 'no_proxy'=>'192.0.2.2') {|env| assert_equal(URI('http://127.0.0.1:8080'), URI("http://192.0.2.1/").find_proxy(env)) assert_nil(URI("http://192.0.2.2/").find_proxy(env)) + + getaddress = IPSocket.method(:getaddress) + begin + class << IPSocket + undef getaddress + def getaddress(host) + host == "example.org" or raise + "192.0.2.1" + end + end + assert_equal(URI('http://127.0.0.1:8080'), URI.parse("http://example.org").find_proxy(env)) + class << IPSocket + undef getaddress + def getaddress(host) + host == "example.org" or raise + "192.0.2.2" + end + end + assert_nil(URI.parse("http://example.org").find_proxy(env)) + ensure + IPSocket.singleton_class.class_eval do + undef getaddress + define_method(:getaddress, getaddress) + end + end } with_proxy_env('http_proxy'=>'http://127.0.0.1:8080', 'no_proxy'=>'example.org') {|env| assert_nil(URI("http://example.org/").find_proxy(env)) |