Write jsonb strings needing an escape as TEXTJ - #5203
Draft
LucaCappelletti94 wants to merge 1 commit into
Draft
Conversation
LucaCappelletti94
force-pushed
the
fuzz-sqlite-jsonb-text-writer
branch
from
September 5, 2026 05:35
a2e58c1 to
b80d046
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
write_jsonb_stringreached forTEXTJonly when a string held a control character, so a string containing a quote or a backslash went out asTEXTwith the character raw in the payload.a"bbecame37 61 22 62, which sqlite reports as invalid throughjson_valid(blob, 8)and refuses injson(), becauseTEXTis defined as a payload that renders as JSON unchanged. Diesel reads its own blob back fine, so what breaks is every sqlite JSON function applied to a column diesel wrote.Any string carrying a byte JSON has to escape, meaning anything below
0x20plus the quote and the backslash, now goes down theTEXTJpath that already existed for control characters.TEXTRAWwould also be well formed, butTEXTJis byte for byte what sqlite's ownjsonb('"a\"b"')writes, so a blob diesel wrote stays comparable with one sqlite wrote for the same value. The scan moved fromchar::is_controlto bytes at the same time, since JSON escapes nothing above0x1Fwhileis_controlalso coversU+007FtoU+009F, which sqlite stores as plainTEXT.This came out of a fuzzer I am writing for diesel's deserialization code.