From c31cc963daac55f6a3bca9da99b619276911dbd7 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 5 Jan 2013 17:46:26 -0700 Subject: Revert "Merge branch 'master-sec'" This reverts commit 88cc1688d0cb828c17706b41a8bd27870f2a2beb, reversing changes made to f049016cd348627bf8db0d72382d7580bf802a79. --- actionpack/lib/action_dispatch/http/request.rb | 7 +++---- actionpack/lib/action_dispatch/middleware/params_parser.rb | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index 31b36eedb0..452809a689 100644 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -276,14 +276,15 @@ module ActionDispatch LOCALHOST =~ remote_addr && LOCALHOST =~ remote_ip end + protected + # Remove nils from the params hash def deep_munge(hash) - hash.each do |k, v| + hash.each_value do |v| case v when Array v.grep(Hash) { |x| deep_munge(x) } v.compact! - hash[k] = nil if v.empty? when Hash deep_munge(v) end @@ -292,8 +293,6 @@ module ActionDispatch hash end - protected - def parse_query(qs) deep_munge(super) end diff --git a/actionpack/lib/action_dispatch/middleware/params_parser.rb b/actionpack/lib/action_dispatch/middleware/params_parser.rb index 951f28f535..2c98ca03a8 100644 --- a/actionpack/lib/action_dispatch/middleware/params_parser.rb +++ b/actionpack/lib/action_dispatch/middleware/params_parser.rb @@ -47,12 +47,12 @@ module ActionDispatch when Proc strategy.call(request.raw_post) when :xml_simple, :xml_node - data = request.deep_munge(Hash.from_xml(request.body.read) || {}) + data = Hash.from_xml(request.raw_post) || {} data.with_indifferent_access when :yaml YAML.load(request.raw_post) when :json - data = request.deep_munge ActiveSupport::JSON.decode(request.body) + data = ActiveSupport::JSON.decode(request.raw_post) data = {:_json => data} unless data.is_a?(Hash) data.with_indifferent_access else -- cgit v1.2.3