Repository navigation
fix: escape CLI span JSON strings - #9
Open
localai-org-maint-bot wants to merge 1 commit into
Open
localai-org-maint-bot wants to merge 1 commit into
localai-org-maint-bot wants to merge 1 commit into
Conversation
Quote labels and span text in both CLI output paths so JSON consumers can read quotes, backslashes, and control bytes. Use explicit lengths to preserve embedded NUL bytes and span boundaries. Add a model-independent serialization test. Native validation remains pending because the maintainer host has no C++ compiler or CMake. Assisted-by: Codex:gpt-6
localai-org-maint-bot
marked this pull request as ready for review
October 11, 2026 03:09
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 #8.
Both
--classifyand token/offset span output currently insert raw text into JSON strings. Quotes, backslashes, and control bytes make the output invalid; embedded NUL also truncates the span.Quote labels and span text through one length-aware helper. Preserve UTF-8 bytes and byte offsets. Add a model-independent CTest target covering escaping, embedded NUL, and bounded slices.
Validation:
git diff --checkpasses. Both GCC release and Clang sanitizer CI builds and model-independent CTest suites pass, including the new test. Local native tests were unavailable because this host has no C++ compiler or CMake. Model inference was not run.To run the new test without model assets or ggml:
It is also registered as
test_jsonin the normal CTest suite. End-to-end output from both CLI modes with model assets and a JSON parser remains untested; the native builds compile both call sites and the model-independent test checks their shared serializer.