fix(extract): snap docstring truncation to UTF-8 codepoint boundary (#1017)#1094
Open
harshitaajoshi wants to merge 2 commits into
Open
fix(extract): snap docstring truncation to UTF-8 codepoint boundary (#1017)#1094harshitaajoshi wants to merge 2 commits into
harshitaajoshi wants to merge 2 commits into
Conversation
…eusData#1017) Signed-off-by: Harshita Joshi <j.harshitaa06@gmail.com>
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.
Fixes #1017
What does this PR do?
Docstring/comment truncation at
MAX_COMMENT_LEN(500 bytes) inextract_comment_text()cuts at a raw byte offset, which can split a multi-byte UTF-8 character and leave an incomplete byte sequence in the storednodes.propertiesJSON. This breaks any strict UTF-8 consumer reading the SQLite database (e.g. Python'ssqlite3module).This PR snaps the truncation point back to the last complete UTF-8 codepoint boundary in
extract_comment_text(), and adds the same guard to theappend_json_string()escape loops in bothpass_definitions.candpass_parallel.c(kept in sync per codebase convention) as defense in depth.A regression test (
docstring_utf8_truncation_boundary_issue1017) crafts a Go comment with 3-byte CJK characters straddling the 500-byte boundary and validates every byte of the extracted docstring is well-formed UTF-8.Checklist
git commit -s) -- required, CI rejectsunsigned commits (DCO, see CONTRIBUTING.md)
make -f Makefile.cbm test)ASan hangs on macOS Tahoe 26.5 (Apple Clang 17) for any binary, including a trivial
int main(){return 0;}. All 6294 tests pass when built without sanitizers (SANITIZE="").make -f Makefile.cbm lint-ci)