tye / rubyception

Rubyception - Realtime Rails log in your browser
MIT License
156 stars 10 forks source link

stack overflow caused by malformed url #19

Open cout opened 11 years ago

cout commented 11 years ago

We noticed an illegal instruction occurring on osx (stack too deep exception on linux), and tracked it down to a url that looked like this:

    http://localhost:3000/portal/protocols/2?1

This causes parsed_nested_params in entry.rb to be passed a hash like this:

    {"1"=>nil, "id"=>"2"}

This results in parsed_nested_params() recursively calling itself until the stack blows up. When it reaches the nil value, parsed_nested_params is called recursively with the original params hash.

Simplest solution is to not use nil as a default:

    def parsed_nested_params params=deep_clone_hash(self.params)
      if params.kind_of? Hash
        params.each do |key,val| 
          params[key] = parsed_nested_params(params[key])
        end
      else
        return params.inspect
      end
      params
    end 
tye commented 11 years ago

Thanks Paul I'll push a new version of the gem in a few days with that fix.