Skip to content

Commit

Permalink
Make filter_parameters work correctly with array parameters.
Browse files Browse the repository at this point in the history
Conflicts:

	actionpack/lib/action_controller/base/filter_parameter_logging.rb
  • Loading branch information
NZKoz committed Jun 27, 2009
1 parent 6720b25 commit 9407f6e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions actionpack/lib/action_controller/base.rb
Expand Up @@ -491,6 +491,10 @@ def filter_parameter_logging(*filter_words, &block)
filtered_parameters[key] = '[FILTERED]'
elsif value.is_a?(Hash)
filtered_parameters[key] = filter_parameters(value)
elsif value.is_a?(Array)
filtered_parameters[key] = value.collect do |item|
filter_parameters(item)
end
elsif block_given?
key = key.dup
value = value.dup if value
Expand Down
3 changes: 2 additions & 1 deletion actionpack/test/controller/filter_params_test.rb
Expand Up @@ -23,7 +23,8 @@ def test_filter_parameters
[{'foo'=>'bar', 'bar'=>'foo'},{'foo'=>'[FILTERED]', 'bar'=>'foo'},%w'foo baz'],
[{'foo'=>'bar', 'baz'=>'foo'},{'foo'=>'[FILTERED]', 'baz'=>'[FILTERED]'},%w'foo baz'],
[{'bar'=>{'foo'=>'bar','bar'=>'foo'}},{'bar'=>{'foo'=>'[FILTERED]','bar'=>'foo'}},%w'fo'],
[{'foo'=>{'foo'=>'bar','bar'=>'foo'}},{'foo'=>'[FILTERED]'},%w'f banana']]
[{'foo'=>{'foo'=>'bar','bar'=>'foo'}},{'foo'=>'[FILTERED]'},%w'f banana'],
[{'baz'=>[{'foo'=>'baz'}]}, {'baz'=>[{'foo'=>'[FILTERED]'}]}, %w(foo)]]

test_hashes.each do |before_filter, after_filter, filter_words|
FilterParamController.filter_parameter_logging(*filter_words)
Expand Down

0 comments on commit 9407f6e

Please sign in to comment.