Skip to content

Commit

Permalink
Fix encoding problem when scrubing parameters
Browse files Browse the repository at this point in the history
Fix #389
  • Loading branch information
Jon de Andres committed Mar 4, 2016
1 parent d429bf0 commit f73cd7f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rollbar/request_data_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def rollbar_filtered_params(sensitive_params, params)
return {} unless params

params.to_hash.inject({}) do |result, (key, value)|
if sensitive_params_regexp =~ key.to_s
if sensitive_params_regexp =~ Rollbar::Encoding.encode(key).to_s
result[key] = rollbar_scrubbed(value)
elsif value.is_a?(Hash)
result[key] = rollbar_filtered_params(sensitive_params, value)
Expand Down
21 changes: 21 additions & 0 deletions spec/rollbar/request_data_extractor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@ class ExtractorDummy

expect(result).to be_kind_of(Hash)
end

context 'with invalid utf8 sequence in key', :if => RUBY_VERSION != '1.8.7' do
let(:data) do
File.read(File.expand_path('../../support/encodings/iso_8859_9', __FILE__)).force_encoding(Encoding::ISO_8859_9)
end
let(:env) do
env = Rack::MockRequest.env_for('/',
'HTTP_HOST' => 'localhost:81',
'HTTP_X_FORWARDED_HOST' => 'example.org:9292',
'CONTENT_TYPE' => 'application/json')

env['rack.session'] = { data => 'foo' }
env
end

it 'doesnt crash' do
result = subject.extract_request_data_from_rack(env)

expect(result).to be_kind_of(Hash)
end
end
end

describe '#rollbar_scrubbed_value' do
Expand Down
1 change: 1 addition & 0 deletions spec/support/encodings/iso_8859_9
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
����������

0 comments on commit f73cd7f

Please sign in to comment.