diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-26 16:08:11 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-26 16:08:11 +0000 |
commit | b5ad2a59511eeede20849ae2aecf1018f5571ff8 (patch) | |
tree | d43d5dcc1447465802452496444bbf48690e067f | |
parent | fe17a46edf43cac07432c1b5a32dd1a9fbe62f7e (diff) |
merge revision(s) 42930: [Backport #8898]
* lib/uri/generic.rb (URI::Generic.find_proxy): return nil if
http_proxy environment variable is empty string.
[ruby-core:57140] [Bug #8898]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@43062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/uri/generic.rb | 32 | ||||
-rw-r--r-- | test/uri/test_generic.rb | 4 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 24 insertions, 20 deletions
@@ -1,3 +1,9 @@ +Fri Sep 27 01:02:59 2013 NARUSE, Yui <naruse@ruby-lang.org> + + * lib/uri/generic.rb (URI::Generic.find_proxy): return nil if + http_proxy environment variable is empty string. + [ruby-core:57140] [Bug #8898] + Fri Sep 27 00:58:57 2013 Zachary Scott <e@zzak.io> * lib/gserver.rb: [DOC] correct gserver.rb license [Bug #8913] diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index 387682b5b5..b1195fdf0b 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -1647,31 +1647,29 @@ module URI proxy_uri = ENV[name] || ENV[name.upcase] end - if proxy_uri && self.hostname + if proxy_uri.nil? || proxy_uri.empty? + return nil + end + + if self.hostname require 'socket' begin addr = IPSocket.getaddress(self.hostname) - proxy_uri = nil if /\A127\.|\A::1\z/ =~ addr + return nil if /\A127\.|\A::1\z/ =~ addr rescue SocketError end end - if proxy_uri - proxy_uri = URI.parse(proxy_uri) - name = 'no_proxy' - if no_proxy = ENV[name] || ENV[name.upcase] - no_proxy.scan(/([^:,]*)(?::(\d+))?/) {|host, port| - if /(\A|\.)#{Regexp.quote host}\z/i =~ self.host && - (!port || self.port == port.to_i) - proxy_uri = nil - break - end - } - end - proxy_uri - else - nil + name = 'no_proxy' + if no_proxy = ENV[name] || ENV[name.upcase] + no_proxy.scan(/([^:,]*)(?::(\d+))?/) {|host, port| + if /(\A|\.)#{Regexp.quote host}\z/i =~ self.host && + (!port || self.port == port.to_i) + return nil + end + } end + URI.parse(proxy_uri) end end end diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb index d22d3c1dd6..e8becd5b8e 100644 --- a/test/uri/test_generic.rb +++ b/test/uri/test_generic.rb @@ -760,12 +760,12 @@ class URI::TestGeneric < Test::Unit::TestCase assert_nil(URI("http://192.0.2.2/").find_proxy) } with_env('http_proxy'=>'') { - assert_equal(URI(''), URI("http://192.0.2.1/").find_proxy) + assert_nil(URI("http://192.0.2.1/").find_proxy) assert_nil(URI("ftp://192.0.2.1/").find_proxy) } with_env('ftp_proxy'=>'') { assert_nil(URI("http://192.0.2.1/").find_proxy) - assert_equal(URI(''), URI("ftp://192.0.2.1/").find_proxy) + assert_nil(URI("ftp://192.0.2.1/").find_proxy) } end @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2013-09-27" -#define RUBY_PATCHLEVEL 318 +#define RUBY_PATCHLEVEL 319 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 9 |