diff options
author | Peter Zhu <peter@peterzhu.ca> | 2018-08-22 11:35:55 -0400 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2018-08-22 15:54:26 -0400 |
commit | ce6166f3079e96836dcd93fc68f1618f53a1d1cc (patch) | |
tree | de26b00dbedf5cedc45659032a4297e93e62b8cb /actionpack/lib/action_dispatch/http | |
parent | 9136bb77a73a9374078f850af056225172f1f211 (diff) | |
download | rails-ce6166f3079e96836dcd93fc68f1618f53a1d1cc.tar.gz rails-ce6166f3079e96836dcd93fc68f1618f53a1d1cc.tar.bz2 rails-ce6166f3079e96836dcd93fc68f1618f53a1d1cc.zip |
Update ParameterFilter to yield original parameters
Diffstat (limited to 'actionpack/lib/action_dispatch/http')
-rw-r--r-- | actionpack/lib/action_dispatch/http/parameter_filter.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/http/parameter_filter.rb b/actionpack/lib/action_dispatch/http/parameter_filter.rb index de11939fa8..09aab631ed 100644 --- a/actionpack/lib/action_dispatch/http/parameter_filter.rb +++ b/actionpack/lib/action_dispatch/http/parameter_filter.rb @@ -56,23 +56,23 @@ module ActionDispatch @blocks = blocks end - def call(original_params, parents = []) - filtered_params = original_params.class.new + def call(params, parents = [], original_params = params) + filtered_params = params.class.new - original_params.each do |key, value| + params.each do |key, value| parents.push(key) if deep_regexps if regexps.any? { |r| key =~ r } value = FILTERED elsif deep_regexps && (joined = parents.join(".")) && deep_regexps.any? { |r| joined =~ r } value = FILTERED elsif value.is_a?(Hash) - value = call(value, parents) + value = call(value, parents, original_params) elsif value.is_a?(Array) - value = value.map { |v| v.is_a?(Hash) ? call(v, parents) : v } + value = value.map { |v| v.is_a?(Hash) ? call(v, parents, original_params) : v } elsif blocks.any? key = key.dup if key.duplicable? value = value.dup if value.duplicable? - blocks.each { |b| b.call(key, value) } + blocks.each { |b| b.arity == 2 ? b.call(key, value) : b.call(key, value, original_params) } end parents.pop if deep_regexps |