Skip to content

Commit

Permalink
Scrub request body content (#832)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anasjabri authored Aug 5, 2020
1 parent 4cff064 commit b79d2d6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ endif::[]
[[release-notes-3.9.0]]
==== 3.9.0 (2020-08-04)
[float]
===== Fixed
- Scrub request body of illegal UTF-8 characters {pull}832[#832]
[float]
===== Added
Expand Down
2 changes: 1 addition & 1 deletion lib/elastic_apm/context_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def get_body(req)
else
body = req.body.read
req.body.rewind
body.byteslice(0, MAX_BODY_LENGTH).force_encoding('utf-8')
body.byteslice(0, MAX_BODY_LENGTH).force_encoding('utf-8').scrub
end
end

Expand Down
1 change: 1 addition & 0 deletions spec/elastic_apm/context_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ module ElasticAPM

expect(result.request.body).to eq '{"something":"everything"}'
expect(result.request.body.encoding).to eq Encoding::UTF_8
expect(result.request.body.valid_encoding?).to be true
end
end
end
Expand Down

0 comments on commit b79d2d6

Please sign in to comment.