diff options
author | Prem Sichanugrist <s@sikac.hu> | 2013-02-19 15:41:03 -0500 |
---|---|---|
committer | Prem Sichanugrist <s@sikac.hu> | 2013-02-20 08:46:44 -0500 |
commit | c9909db9f2f81575ef2ea2ed3b4e8743c8d6f1b9 (patch) | |
tree | 2ef8cb5fd3668585da1129f3abb7dcc57e7abb19 /actionpack/lib/action_dispatch/middleware | |
parent | e1456ad95ef45971ff1593be3d1364ed42bcd9ee (diff) | |
download | rails-c9909db9f2f81575ef2ea2ed3b4e8743c8d6f1b9.tar.gz rails-c9909db9f2f81575ef2ea2ed3b4e8743c8d6f1b9.tar.bz2 rails-c9909db9f2f81575ef2ea2ed3b4e8743c8d6f1b9.zip |
Remove XML Parser from ActionDispatch
If you want an ability to parse XML parameters, please install
`actionpack-xml_parser` gem.
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/params_parser.rb | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/params_parser.rb b/actionpack/lib/action_dispatch/middleware/params_parser.rb index 0898ad82dd..0fa1e9b859 100644 --- a/actionpack/lib/action_dispatch/middleware/params_parser.rb +++ b/actionpack/lib/action_dispatch/middleware/params_parser.rb @@ -13,10 +13,7 @@ module ActionDispatch end end - DEFAULT_PARSERS = { - Mime::XML => :xml_simple, - Mime::JSON => :json - } + DEFAULT_PARSERS = { Mime::JSON => :json } def initialize(app, parsers = {}) @app, @parsers = app, DEFAULT_PARSERS.merge(parsers) @@ -36,19 +33,13 @@ module ActionDispatch return false if request.content_length.zero? - mime_type = content_type_from_legacy_post_data_format_header(env) || - request.content_mime_type - - strategy = @parsers[mime_type] + strategy = @parsers[request.content_mime_type] return false unless strategy case strategy when Proc strategy.call(request.raw_post) - when :xml_simple, :xml_node - data = request.deep_munge(Hash.from_xml(request.body.read) || {}) - data.with_indifferent_access when :json data = ActiveSupport::JSON.decode(request.body) data = {:_json => data} unless data.is_a?(Hash) @@ -56,23 +47,12 @@ module ActionDispatch else false end - rescue Exception => e # YAML, XML or Ruby code block errors + rescue Exception => e # JSON or Ruby code block errors logger(env).debug "Error occurred while parsing request parameters.\nContents:\n\n#{request.raw_post}" raise ParseError.new(e.message, e) end - def content_type_from_legacy_post_data_format_header(env) - if x_post_format = env['HTTP_X_POST_DATA_FORMAT'] - case x_post_format.to_s.downcase - when 'yaml' then return Mime::YAML - when 'xml' then return Mime::XML - end - end - - nil - end - def logger(env) env['action_dispatch.logger'] || ActiveSupport::Logger.new($stderr) end |