Preserve embedded NUL bytes in TEXT values#8
Open
sbking wants to merge 1 commit into
Open
Conversation
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.
Summary
sqlite3_bind_textcurrently passes-1as the byte length, and the Emscripten string return conversion used bycolumn_textalso treats NUL as a terminator. As a result, TEXT values containing embedded NUL bytes are truncated in both directions.sqlite3_bind_textsqlite3_column_bytesrange while retaining Emscripten's existing UTF-8 decoding behaviorTesting
bind_textinputs, leading U+FEFF, and existing malformed UTF-8 decodingprettier --check src/sqlite-api.js .changeset/fuzzy-spoons-smile.mdnode --check test/api_statements.jsThe repository's full
api.test.jsexceeded Web Test Runner's file-level finish timeout on both pristinemain(120 seconds) and this branch (300 seconds), so I don't have a full-suite result for either tree.References
sqlite3_bind_textcontract specifies that a negative byte length stops at the first NUL, while an explicit non-negative length preserves embedded NULs.sqlite3_column_bytesas the full UTF-8 byte length and recommends callingsqlite3_column_textbeforesqlite3_column_bytes.Checklist
non-exclusive, royalty-free, irrevocable copyright license to reproduce, prepare
derivative works of, publicly display, sublicense, and distribute this
Contribution and such derivative works.
Contribution contains no content requiring a license from any third party.