#102 new
Chris Sepic

parse_query and parse_nested_query handle duplicate parameters differently

Reported by Chris Sepic | August 12th, 2010 @ 04:38 PM

for a request with this query string:

?foo=bar&foo=baz

I expected Rack to keep both values for 'foo'.

Utils.parse_query and Utils.parse_nested_query handle duplicate query
params differently. With parse_nested_query, the first of the
duplicate params is discarded. With parse_query, an array is created:

>> Rack::Utils.parse_nested_query("foo=bar&foo=baz")
=> {"foo"=>"baz"}
>> Rack::Utils.parse_query("foo=bar&foo=baz")
=> {"foo"=>["bar", "baz"]}

There's no official HTML spec on how to handle this, but I think both
methods should have the same behavior, whichever way is deemed
"correct." There is a test for the behavior of parse_nested_query:

Rack::Utils.parse_nested_query("foo=bar&foo=quux").
      should.equal "foo" => "quux"

but no similar test for parse_query.

I'd prefer the behavior of parse_query here.

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Pages