mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Wed Jul 4 08:45:41 2012 Takeyuki FUJIOKA <xibbar@ruby-lang.org>
* lib/cgi/core.rb: fix bug: When query parameter is 'id=123&id', cgi['id'] => '123' is correct. First parameter is valid. [Feature #6621] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
38ca5cca00
commit
9c746e35ad
2 changed files with 7 additions and 6 deletions
|
@ -367,12 +367,13 @@ class CGI
|
|||
params = {}
|
||||
query.split(/[&;]/).each do |pairs|
|
||||
key, value = pairs.split('=',2).collect{|v| CGI::unescape(v) }
|
||||
if key && value
|
||||
params.has_key?(key) ? params[key].push(value) : params[key] = [value]
|
||||
elsif key
|
||||
params[key]=[]
|
||||
end
|
||||
|
||||
next unless key
|
||||
|
||||
params[key] ||= []
|
||||
params[key].push(value) if value
|
||||
end
|
||||
|
||||
params.default=[].freeze
|
||||
params
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@ class CGICoreTest < Test::Unit::TestCase
|
|||
def test_cgi_core_params_GET
|
||||
@environ = {
|
||||
'REQUEST_METHOD' => 'GET',
|
||||
'QUERY_STRING' => 'id=123&id=456&id=&str=%40h+%3D%7E+%2F%5E%24%2F',
|
||||
'QUERY_STRING' => 'id=123&id=456&id=&id&str=%40h+%3D%7E+%2F%5E%24%2F',
|
||||
'HTTP_COOKIE' => '_session_id=12345; name1=val1&val2;',
|
||||
'SERVER_SOFTWARE' => 'Apache 2.2.0',
|
||||
'SERVER_PROTOCOL' => 'HTTP/1.1',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue