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

ruby-changes:30101

From: naruse <ko1@a...>
Date: Wed, 24 Jul 2013 19:52:26 +0900 (JST)
Subject: [ruby-changes:30101] naruse:r42153 (trunk): * lib/uri/generic.rb (find_proxy): raise BadURIError if the URI is

naruse	2013-07-24 19:52:15 +0900 (Wed, 24 Jul 2013)

  New Revision: 42153

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

  Log:
    * lib/uri/generic.rb (find_proxy): raise BadURIError if the URI is
      a relative URI. [Bug #8645]

  Modified files:
    trunk/ChangeLog
    trunk/lib/uri/generic.rb
    trunk/test/uri/test_generic.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42152)
+++ ChangeLog	(revision 42153)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jul 24 19:49:54 2013  NARUSE, Yui  <naruse@r...>
+
+	* lib/uri/generic.rb (find_proxy): raise BadURIError if the URI is
+	  a relative URI. [Bug #8645]
+
 Wed Jul 24 18:56:06 2013  Koichi Sasada  <ko1@a...>
 
 	* vm_insnhelper.c (vm_expandarray): use RARRAY_RAWPTR() instead of
Index: lib/uri/generic.rb
===================================================================
--- lib/uri/generic.rb	(revision 42152)
+++ lib/uri/generic.rb	(revision 42153)
@@ -1611,6 +1611,7 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L1611
     # http_proxy is not used too if the variable is case insensitive.
     # CGI_HTTP_PROXY can be used instead.
     def find_proxy
+      raise BadURIError, "relative URI: #{self}" if self.relative?
       name = self.scheme.downcase + '_proxy'
       proxy_uri = nil
       if name == 'http_proxy' && ENV.include?('REQUEST_METHOD') # CGI?
Index: test/uri/test_generic.rb
===================================================================
--- test/uri/test_generic.rb	(revision 42152)
+++ test/uri/test_generic.rb	(revision 42153)
@@ -736,6 +736,7 @@ class URI::TestGeneric < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/uri/test_generic.rb#L736
   # 192.0.2.0/24 is TEST-NET.  [RFC3330]
 
   def test_find_proxy
+    assert_raise(URI::BadURIError){ URI("foo").find_proxy }
     with_env({}) {
       assert_nil(URI("http://192.0.2.1/").find_proxy)
       assert_nil(URI("ftp://192.0.2.1/").find_proxy)

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

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