aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rwxr-xr-xactionpack/lib/action_controller/base.rb11
-rwxr-xr-xactionpack/lib/action_controller/cgi_ext/cgi_methods.rb14
2 files changed, 16 insertions, 9 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index ab8cc1802c..e4877f82fd 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -278,16 +278,11 @@ module ActionController #:nodoc:
# behavior you can re-register XmlSimple as application/xml handler and enable application/x-yaml like
# this:
#
- # ActionController::Base.param_parsers['application/xml'] = Proc.new do |data|
- # XmlSimple.xml_in(data, 'ForceArray' => false)
- # end
- #
- # ActionController::Base.param_parsers['application/x-yaml'] = Proc.new do |data|
- # |post| YAML.load(post)
- # end
+ # ActionController::Base.param_parsers['application/xml'] = :xml_simple
+ # ActionController::Base.param_parsers['application/x-yaml'] = :yaml
#
@@param_parsers = {
- 'application/xml' => Proc.new { |post| node = XmlNode.from_xml(post); { node.node_name => node } },
+ 'application/xml' => :xml_node
}
cattr_accessor :param_parsers
diff --git a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
index 89f982f56f..feab806077 100755
--- a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
+++ b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
@@ -59,7 +59,19 @@ class CGIMethods #:nodoc:
end
def self.parse_formatted_request_parameters(format, raw_post_data)
- ActionController::Base.param_parsers[format].call(raw_post_data) || {}
+ params = case strategy = ActionController::Base.param_parsers[format]
+ when Proc
+ strategy.call(raw_post_data)
+ when :xml_node
+ node = XmlNode.from_xml(raw_post_data)
+ { node.node_name => node }
+ when :xml_simple
+ XmlSimple.xml_in(raw_post_data, 'ForceArray' => false)
+ when :yaml
+ YAML.load(raw_post_data)
+ end
+
+ params || {}
rescue Object => e
{ "exception" => "#{e.message} (#{e.class})", "backtrace" => e.backtrace,
"raw_post_data" => raw_post_data, "format" => format }