mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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/trunk@42930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0c252b43ad
commit
80d8216415
3 changed files with 23 additions and 19 deletions
|
@ -1,3 +1,9 @@
|
|||
Thu Sep 12 14:58:58 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 13 10:40:28 2013 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib/rubygems: Update to RubyGems 2.1.3
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue