Jean-Philippe Garcia Ballester
2006-Aug-30 15:14 UTC
Ajax request containing special characters
Hello ! Fooling around with Rails, I came accross a strang thing which I think is a bug : when an Ajax request is sent with an observer, the content of the field is sent directly in post, and is then parsed by CGI::parse. If the field content starts with ''&'' and then another character, let''s say ''a'', CGI::parse set @params with {nil => [nil], "a" => [nil]}. Rails then fails with the following backtrace : You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occured while evaluating nil.include? ./script/../config/../vendor/rails/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb:49:in `parse_request_parameters'' ./script/../config/../vendor/rails/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb:47:in `parse_request_parameters'' ./script/../config/../vendor/rails/actionpack/lib/action_controller/cgi_process.rb:71:in `request_parameters'' ./script/../config/../vendor/rails/actionpack/lib/action_controller/request.rb:13:in `parameters'' ./script/../config/../vendor/rails/actionpack/lib/action_controller/session_management.rb:122:in `set_session_options_without_components'' ./script/../config/../vendor/rails/actionpack/lib/action_controller/components.rb:178:in `set_session_options'' ./script/../config/../vendor/rails/actionpack/lib/action_controller/session_management.rb:116:in `process'' ./script/../config/../vendor/rails/railties/lib/dispatcher.rb:38:in `dispatch'' ./script/../config/../vendor/rails/railties/lib/webrick_server.rb:115:in `handle_dispatch'' ./script/../config/../vendor/rails/railties/lib/webrick_server.rb:81:in `service'' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'' /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'' /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'' /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'' /usr/lib/ruby/1.8/webrick/server.rb:23:in `start''^M /usr/lib/ruby/1.8/webrick/server.rb:82:in `start''^M ./script/../config/../vendor/rails/railties/lib/webrick_server.rb:67:in `dispatc\h'' ./script/../config/../vendor/rails/railties/lib/commands/servers/webrick.rb:59^M/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require'' ./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies\.rb:147:in `require'' ./script/../config/../vendor/rails/railties/lib/commands/server.rb:30 script/server:3 Should observe_field method escape special characters? Thanks for your help. -- Jean-Philippe Garcia Ballester