Skip to content

Commit

Permalink
Merge pull request #432 from loybert/fix/dont-break-when-filtering-ar…
Browse files Browse the repository at this point in the history
…rays-of-arrays

[Fix] filtering multidim-arrays from cgi-data's 'action_dispatch.cookies'
  • Loading branch information
kyrylo committed Oct 20, 2015
2 parents 942a2e6 + 8601406 commit e61522c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/airbrake/utils/params_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def whitelist_key?(key)

def filter(hash)
hash.each do |key, value|
if filter_key?(key)
if hash.is_a?(Hash) && filter_key?(key)
hash[key] = "[FILTERED]"
elsif value.respond_to?(:to_hash)
filter(hash[key])
Expand Down
11 changes: 11 additions & 0 deletions test/params_cleaner_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,15 @@ def assert_filters_hash(attribute)
assert_match(/\A#<(Temp)?[Ff]ile:0x.+>\z/, clean_params.parameters[:files][0])
assert_match(/\A#<IO:0x.+>\z/, clean_params.parameters[:files][1])
end

should "not break on filtering multi-dimensional array as possible in action_dispatch.cookies" do
original = { 'cgi_cookies_to_filter' => [['any_cookie_key', 'some_cookie_value'], ['secret', 'some_secret_value']] }
clean_params = clean(:params_filters => [:secret],
:params_whitelist_filters => [:secret],
:parameters => original)
assert_nothing_raised do
clean_params.send(:parameters)
end
end

end

0 comments on commit e61522c

Please sign in to comment.