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

ruby-changes:41742

From: nobu <ko1@a...>
Date: Sat, 13 Feb 2016 17:12:04 +0900 (JST)
Subject: [ruby-changes:41742] nobu:r53816 (trunk): no_proxy with whitespaces and leading dots

nobu	2016-02-13 17:12:21 +0900 (Sat, 13 Feb 2016)

  New Revision: 53816

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53816

  Log:
    no_proxy with whitespaces and leading dots
    
    * lib/uri/generic.rb (find_proxy): exclude white-spaces and allow
      for a leading dot in the domain name in no_proxy.
      [ruby-core:54542] [Feature #8317]
    
    The previous implementation wouldn't allow for white-spaces nor a leading dot
    in the domain name. The latter is described in the wget documentation as a valid case.
    
    By being more strict on the characters, which are counted to a domainname,
    we allow for white-spaces.
    Also, a possible leading dot will be handled gracefully.
    
    [Fix GH-285]

  Modified files:
    trunk/ChangeLog
    trunk/lib/uri/generic.rb
    trunk/test/uri/test_generic.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53815)
+++ ChangeLog	(revision 53816)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Feb 13 17:11:58 2016  Fabian Wiesel  <fabian.wiesel@s...>
+
+	* lib/uri/generic.rb (find_proxy): exclude white-spaces and allow
+	  for a leading dot in the domain name in no_proxy.
+	  [ruby-core:54542] [Feature #8317]
+
 Fri Feb 12 12:20:56 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* error.c (name_err_initialize, nometh_err_initialize): [DOC] fix
Index: test/uri/test_generic.rb
===================================================================
--- test/uri/test_generic.rb	(revision 53815)
+++ test/uri/test_generic.rb	(revision 53816)
@@ -835,6 +835,10 @@ class URI::TestGeneric < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/uri/test_generic.rb#L835
       assert_nil(URI("http://example.org/").find_proxy)
       assert_nil(URI("http://www.example.org/").find_proxy)
     }
+    with_env('http_proxy'=>'http://127.0.0.1:8080', 'no_proxy'=>'.example.org') {
+      assert_nil(URI("http://example.org/").find_proxy)
+      assert_nil(URI("http://www.example.org/").find_proxy)
+    }
   end
 
   def test_find_proxy_bad_value
Index: lib/uri/generic.rb
===================================================================
--- lib/uri/generic.rb	(revision 53815)
+++ lib/uri/generic.rb	(revision 53816)
@@ -1546,7 +1546,7 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L1546
 
       name = 'no_proxy'
       if no_proxy = ENV[name] || ENV[name.upcase]
-        no_proxy.scan(/([^:,]*)(?::(\d+))?/) {|host, port|
+        no_proxy.scan(/(?!\.)([^:,\s]+)(?::(\d+))?/) {|host, port|
           if /(\A|\.)#{Regexp.quote host}\z/i =~ self.host &&
             (!port || self.port == port.to_i)
             return nil

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

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