diff options
author | Jamis Buck <jamis@37signals.com> | 2006-03-18 18:56:19 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2006-03-18 18:56:19 +0000 |
commit | 79a82e3a97e1ad9d057682ea3b4dc60fb714ec8a (patch) | |
tree | 924b38fd74e861bf50e67ef03a9f6dde0f9e44b3 | |
parent | 50103b86e6f5e6aa82448d6bfdafeac34e0c8caa (diff) | |
download | rails-79a82e3a97e1ad9d057682ea3b4dc60fb714ec8a.tar.gz rails-79a82e3a97e1ad9d057682ea3b4dc60fb714ec8a.tar.bz2 rails-79a82e3a97e1ad9d057682ea3b4dc60fb714ec8a.zip |
Make sure xml_simple requests don't blow up if an empty request body is recieved
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3936 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rwxr-xr-x | actionpack/lib/action_controller/cgi_ext/cgi_methods.rb | 11 | ||||
-rw-r--r-- | actionpack/test/controller/webservice_test.rb | 6 |
2 files changed, 12 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb index f19e70839d..941646c530 100755 --- a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb +++ b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb @@ -63,11 +63,12 @@ class CGIMethods #:nodoc: when Proc strategy.call(raw_post_data) when :xml_simple - typecast_xml_value(XmlSimple.xml_in(raw_post_data, - 'forcearray' => false, - 'forcecontent' => true, - 'keeproot' => true, - 'contentkey' => '__content__')) + raw_post_data.blank? ? nil : + typecast_xml_value(XmlSimple.xml_in(raw_post_data, + 'forcearray' => false, + 'forcecontent' => true, + 'keeproot' => true, + 'contentkey' => '__content__')) when :yaml YAML.load(raw_post_data) when :xml_node diff --git a/actionpack/test/controller/webservice_test.rb b/actionpack/test/controller/webservice_test.rb index 5cf92146a8..9874b2092b 100644 --- a/actionpack/test/controller/webservice_test.rb +++ b/actionpack/test/controller/webservice_test.rb @@ -92,6 +92,12 @@ class WebServiceTest < Test::Unit::TestCase assert_equal 'content...', @controller.params["summary"] assert_equal 'SimpleXml', @controller.params["title"] end + + def test_use_xml_ximple_with_empty_request + ActionController::Base.param_parsers[Mime::XML] = :xml_simple + assert_nothing_raised { process('POST', 'application/xml', "") } + assert_equal "", @controller.response.body + end def test_deprecated_request_methods process('POST', 'application/x-yaml') |