summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-18 07:32:08 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-18 07:32:08 +0000
commit9381cd1184f8230de4c60b27d3c788107bfa292c (patch)
tree387a45af651497f4d80b832394c7f0e4e2fcb092 /lib
parent69305da74d9d6f3c0da668b9a95d872eee27e527 (diff)
* 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
Diffstat (limited to 'lib')
-rw-r--r--lib/uri/generic.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index 2c453dc9db..0435fd25ce 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -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