forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
json: generate hex escapes when utf8 is not valid, and check that tho…
…se are correct in tests. (envoyproxy#35972) Commit Message: Currently the JSON serializer, when sanitizing a string that is not valid UTF-8, generates correct JavaScript string syntax. However, the syntax is not valid JSON; in JSON you must use 4-digit hex escapes, and 3-digit octal escapes are not in spec. This was working for the Envoy admin detailed histograms, which would load the histogram detail via JSON, but parse it with JavaScript. However it does not pass validation. Note that this would only show up if the strings (e.g. stat names, prefixes) are not valid utf-8. This PR changes the escape syntax to hex, so it will pass JSON validation. It also adds a test that checks to see the escaped JSON strings match the input. Additional Description: These extra checks were added in anticipation of helping to test envoyproxy#35936 Risk Level: low Testing: //test/common/json/... Docs Changes: n/a Release Notes: n/a Platform Specific Features: n/a --------- Signed-off-by: Joshua Marantz <[email protected]>
- Loading branch information
Showing
4 changed files
with
111 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters