aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/cgi_ext/cgi_methods.rb')
-rwxr-xr-xactionpack/lib/action_controller/cgi_ext/cgi_methods.rb25
1 files changed, 19 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
index 3736353b53..0884d0ab89 100755
--- a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
+++ b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
@@ -1,4 +1,5 @@
require 'cgi'
+require 'action_controller/vendor/xml_simple'
# Static methods for parsing the query and request parameters that can be used in
# a CGI extension class or testing in isolation.
@@ -16,13 +17,13 @@ class CGIMethods #:nodoc:
v = CGI.unescape(v) unless v.nil?
if k =~ /(.*)\[\]$/
- if parsed_params.has_key? $1
- parsed_params[$1] << v
- else
- parsed_params[$1] = [v]
- end
+ if parsed_params.has_key? $1
+ parsed_params[$1] << v
+ else
+ parsed_params[$1] = [v]
+ end
else
- parsed_params[k] = v.nil? ? nil : v
+ parsed_params[k] = v.nil? ? nil : v
end
}
@@ -47,6 +48,18 @@ class CGIMethods #:nodoc:
return parsed_params
end
+ def self.parse_formatted_request_parameters(format, raw_post_data)
+ case format
+ when :xml
+ return XmlSimple.xml_in(raw_post_data, 'ForceArray' => false)
+ when :yaml
+ return YAML.load(raw_post_data)
+ end
+ rescue Object => e
+ { "exception" => "#{e.message} (#{e.class})", "backtrace" => e.backtrace,
+ "raw_post_data" => raw_post_data, "format" => format }
+ end
+
private
def CGIMethods.get_typed_value(value)
if value.respond_to?(:content_type) && !value.content_type.empty?