json: disallow overlong and out-of-range UTF-8 #4097
Merged
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.
Fixes #2379
Today we done learn a thing or two about UTF-8 and JSON! If you are curious about the encoding-related details, please see my commit message 💀 🔨
Changes
Notes
and preëmption of awkward feels
\uDEAD
case in std.json failing test cases #2379 was already intentionally being allowed. See my comment on that issue for details, and investigate handling of windows file paths which are invalid utf-16le #1774, Windows paths allow unpaired surrogates #2565 for related discussion.--emit asm
shows me that0x80...0xBF =>
adds 10-ish instructions over a bitwise op, but I figured an optimizing stage2 will take care of that someday. I addedsequence_first_byte
instead of reusing an existing field. I'm open to changing any of that.