aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2010-01-20 09:55:33 -0600
committerJoshua Peek <josh@joshpeek.com>2010-01-20 09:55:58 -0600
commit87bcf1aa15f8edb4287e1916b65a2c523f765e86 (patch)
treea70b52766cac796abbeb62a5af97e312a08672a2
parentf7d94cdc6d01617ff4579fda6a56a3e94be47ffe (diff)
downloadrails-87bcf1aa15f8edb4287e1916b65a2c523f765e86.tar.gz
rails-87bcf1aa15f8edb4287e1916b65a2c523f765e86.tar.bz2
rails-87bcf1aa15f8edb4287e1916b65a2c523f765e86.zip
Request#filter_parameters and filter_env
-rw-r--r--actionpack/lib/action_dispatch/http/parameters.rb26
1 files changed, 24 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/http/parameters.rb b/actionpack/lib/action_dispatch/http/parameters.rb
index 97546d5f93..68ba3637bf 100644
--- a/actionpack/lib/action_dispatch/http/parameters.rb
+++ b/actionpack/lib/action_dispatch/http/parameters.rb
@@ -29,9 +29,31 @@ module ActionDispatch
def path_parameters
@env["action_dispatch.request.path_parameters"] ||= {}
end
-
- private
+ def filter_parameters
+ # TODO: Remove dependency on controller
+ if controller = @env['action_controller.instance']
+ controller.send(:filter_parameters, params)
+ else
+ params
+ end
+ end
+
+ def filter_env
+ if controller = @env['action_controller.instance']
+ @env.map do |key, value|
+ if (key =~ /RAW_POST_DATA/i)
+ '[FILTERED]'
+ else
+ controller.send(:filter_parameters, {key => value}).values[0]
+ end
+ end
+ else
+ env
+ end
+ end
+
+ private
# Convert nested Hashs to HashWithIndifferentAccess
def normalize_parameters(value)
case value