Uncaught Type Error from normalize_params #362

Closed
mikeycgto opened this Issue Mar 12, 2012 · 1 comment

Projects

None yet

1 participant

@mikeycgto

I'm able to trigger an uncaught exception in Rack. Here is the backtrace:

 expected Array (got String) for param `x'
 rack (1.4.1) lib/rack/utils.rb:108:in `normalize_params'
 rack (1.4.1) lib/rack/utils.rb:90:in `block in parse_nested_query'
 rack (1.4.1) lib/rack/utils.rb:87:in `each'
 rack (1.4.1) lib/rack/utils.rb:87:in `parse_nested_query'
 rack (1.4.1) lib/rack/request.rb:334:in `parse_query'
 rack (1.4.1) lib/rack/request.rb:186:in `GET'

The exception is triggered by doing:

GET /?x=&x[]=

This is also happens on POST (didn't try other verbs but I'd imagine it's all the same). Note that the order of the parameters do matter. If you do x[]=&x= it does not fail.

@mikeycgto

Looked at the code and accompanying tests for Rack::Utils.parse_nested_query and this is how it should behave.

I accidentally triggered this in a Rails app and also tested it against Sinatra. Was just surprised that I was able to trigger an error so deep down.

@mikeycgto mikeycgto closed this Mar 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment