Fix issue where json_encode quietly fails due to binary data inside telescope entry #1266
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have encountered an issue, where the telescope did not save any requests for me.
Example of issue:
Send a request to the application with telescope enabled:
/?my-parameter=4jOH%1a%14)%1a7%d1%60%8cd%40t%94%86m%e6%f8
The expected result: Request to be logged (if so configured) in the telescope.
Actual result: Nothing is saved (as if no request was sent)
Cause:
json_encode in some situations fails to encode binary data, silently fails, and returns false.
Possible abuse:
This can also be abused and requests which are generated for malicious purposes could be hidden from the telescope simply by including a bit of binary data which fails to json_encode.
Solution:
We can tell json_encode to replace invalid utf8 characters to \0xfffd. Which corrupts the original request before saving it database, however, it seems like the lesser of two evils.