Rack::Utils.parse_nested_query weirdness
Reported by Bruno Michel | August 6th, 2009 @ 10:22 AM
Hi,
I found two cases where Rack::Utils.parse_nested_query returns
weird results :
Rack::Utils.parse_nested_query("x[][y][w]=1&x[][z]=2&x[][y][w]=3&x[][z]=4")
=> {"x"=>[{"y"=>{"w"=>"3"},
"z"=>"2"}, {"z"=>"4"}]}
Rack::Utils.parse_nested_query("x[][y][w]=1&x[][y][t]=2&x[][y][w]=3&x[][y][t]=4")
=> {"x"=>[{"y"=>{"w"=>"3", "t"=>"4"}}]}
In particular, I'm perplex that some values are rejected. As I've not found which document specify how should query be parsed, I don't know if it's an expected result or a bug.
Comments and changes to this ticket
-
Arnaud Berthomier August 6th, 2009 @ 10:31 AM
Hey,
On the same topic...
Rack::Utils.parse_nested_query("x[][y][w]=1&x[][y][w]=2&x[][y][w]=3&x[][y][w]=4") # => {"x"=>[{"y"=>{"w"=>"4"}}]}
Only the last value is seen here ; shouldn't this be more like this ?
{"x"=>[{"y"=>{"w"=>"1"}},{"y"=>{"w"=>"2"}},{"y"=>{"w"=>"3"}},{"y"=>{"w"=>"4"}}]}
-
josh December 11th, 2009 @ 02:38 AM
- Assigned user set to josh
- State changed from new to wontfix
The parser intentionally clobbers earlier parameters. In the simplest example "foo=bar&foo=baz" => {foo => baz}. In gets kind of weird with deeply nested params. In the those examples you have ambiguous types so the latter type clobbers the first instead of merging with it.
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.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป