mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/uri/generic.rb (URI::Generic.build): duplicate args before adding
new items. (don't change arguments) * lib/uri/generic.rb (URI::Generic.build): use URI::Generic::COMPONENT if this method is called from URI::Generic. * lib/uri/generic.rb (URI::Generic.build2): escape only if the item is a String. * lib/uri/generic.rb (URI::Generic.build2): use DEFAULT_PARSER because it doesn't have parser method. [Bug #6420] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
69305da74d
commit
9381cd1184
3 changed files with 29 additions and 5 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
Fri May 18 15:20:56 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* lib/uri/generic.rb (URI::Generic.build): duplicate args before adding
|
||||
new items. (don't change arguments)
|
||||
|
||||
* lib/uri/generic.rb (URI::Generic.build): use URI::Generic::COMPONENT
|
||||
if this method is called from URI::Generic.
|
||||
|
||||
* lib/uri/generic.rb (URI::Generic.build2): escape only if the item is
|
||||
a String.
|
||||
|
||||
* lib/uri/generic.rb (URI::Generic.build2): use DEFAULT_PARSER because
|
||||
it doesn't have parser method. [Bug #6420]
|
||||
|
||||
Fri May 18 15:54:07 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||
|
||||
* ext/zlib/extconf.rb: Use an exception instaed of bare puts.
|
||||
|
|
|
@ -86,8 +86,8 @@ module URI
|
|||
rescue InvalidComponentError
|
||||
if args.kind_of?(Array)
|
||||
return self.build(args.collect{|x|
|
||||
if x
|
||||
parser.escape(x)
|
||||
if x.is_a?(String)
|
||||
DEFAULT_PARSER.escape(x)
|
||||
else
|
||||
x
|
||||
end
|
||||
|
@ -96,7 +96,7 @@ module URI
|
|||
tmp = {}
|
||||
args.each do |key, value|
|
||||
tmp[key] = if value
|
||||
parser.escape(value)
|
||||
DEFAULT_PARSER.escape(value)
|
||||
else
|
||||
value
|
||||
end
|
||||
|
@ -121,7 +121,7 @@ module URI
|
|||
def self.build(args)
|
||||
if args.kind_of?(Array) &&
|
||||
args.size == ::URI::Generic::COMPONENT.size
|
||||
tmp = args
|
||||
tmp = args.dup
|
||||
elsif args.kind_of?(Hash)
|
||||
tmp = ::URI::Generic::COMPONENT.collect do |c|
|
||||
if args.include?(c)
|
||||
|
@ -131,8 +131,9 @@ module URI
|
|||
end
|
||||
end
|
||||
else
|
||||
component = self.class.component rescue ::URI::Generic::COMPONENT
|
||||
raise ArgumentError,
|
||||
"expected Array of or Hash of components of #{self.class} (#{self.class.component.join(', ')})"
|
||||
"expected Array of or Hash of components of #{self.class} (#{component.join(', ')})"
|
||||
end
|
||||
|
||||
tmp << nil
|
||||
|
|
|
@ -723,4 +723,13 @@ class URI::TestGeneric < Test::Unit::TestCase
|
|||
u.hostname = "::1"
|
||||
assert_equal("http://[::1]/bar", u.to_s)
|
||||
end
|
||||
|
||||
def test_build
|
||||
URI::Generic.build(['http', nil, 'example.com', 80, nil, '/foo', nil, nil, nil])
|
||||
end
|
||||
|
||||
def test_build2
|
||||
URI::Generic.build2(path: "/foo bar/baz")
|
||||
URI::Generic.build2(['http', nil, 'example.com', 80, nil, '/foo bar' , nil, nil, nil])
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue