Skip to content

Commit

Permalink
Handle non-utf-8 characters on an invalid url request
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanHouston committed Aug 8, 2016
1 parent 3a7b75e commit 947f04d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/json_and_string_parameter_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def run(param_key, param_value)
# no need to do anything with param_value as it's nil
elsif param_value.is_a?(String)
if param_key =~ @string_regexp
param_value.gsub!(/^.*$/, '[FILTERED]')
param_value.gsub!(/^.*$/, '[FILTERED]').encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
else
@value_filters.each do |value_filter|
param_value.gsub!(/^.*$/, '[FILTERED]') if value_filter.call(param_value)
param_value.gsub!(/^.*$/, '[FILTERED]').encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '') if value_filter.call(param_value.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: ''))
end
end
elsif param_value.is_a?(Hash)
Expand Down
6 changes: 6 additions & 0 deletions spec/features/unknown_route_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@
expect(page).to have_http_status :not_found
end

scenario "with non-utf-8 characters" do
visit "/%E2%EF%BF%BD%A6"

expect(page).to have_http_status :not_found
end

end

0 comments on commit 947f04d

Please sign in to comment.