[前][次][番号順一覧][スレッド一覧]

ruby-changes:30851

From: naruse <ko1@a...>
Date: Fri, 13 Sep 2013 13:57:32 +0900 (JST)
Subject: [ruby-changes:30851] naruse:r42930 (trunk): * lib/uri/generic.rb (URI::Generic.find_proxy): return nil if

naruse	2013-09-13 13:57:25 +0900 (Fri, 13 Sep 2013)

  New Revision: 42930

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42930

  Log:
    * lib/uri/generic.rb (URI::Generic.find_proxy): return nil if
      http_proxy environment variable is empty string.
      [ruby-core:57140] [Bug #8898]

  Modified files:
    trunk/ChangeLog
    trunk/lib/uri/generic.rb
    trunk/test/uri/test_generic.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42929)
+++ ChangeLog	(revision 42930)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Sep 12 14:58:58 2013  NARUSE, Yui  <naruse@r...>
+
+	* 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@s...>
 
 	* lib/rubygems:  Update to RubyGems 2.1.3
Index: lib/uri/generic.rb
===================================================================
--- lib/uri/generic.rb	(revision 42929)
+++ lib/uri/generic.rb	(revision 42930)
@@ -1647,31 +1647,29 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L1647
         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
Index: test/uri/test_generic.rb
===================================================================
--- test/uri/test_generic.rb	(revision 42929)
+++ test/uri/test_generic.rb	(revision 42930)
@@ -760,12 +760,12 @@ class URI::TestGeneric < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/uri/test_generic.rb#L760
       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
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]