fix: parser mishandles escapes in quoted arguments#18
Open
TopangaLudwitt wants to merge 1 commit intoopenclaw:mainfrom
Open
fix: parser mishandles escapes in quoted arguments#18TopangaLudwitt wants to merge 1 commit intoopenclaw:mainfrom
TopangaLudwitt wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Single-quoted strings now treat all characters as literal (no escape processing), matching POSIX shell semantics. Double-quoted strings now preserve backslash escape sequences (both backslash and next char are kept) instead of stripping the backslash. This fixes two failure modes: 1. Escaped apostrophes in single-quoted JSON caused 'Unclosed quote' errors 2. JSON escape sequences in double-quoted --args-json payloads were corrupted (backslashes stripped, altering payload semantics) Added 3 new parser tests for escape handling in both quote types. Fixes openclaw#17
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
Fix
tokenizeCommandescape handling in single-quoted and double-quoted strings.Problem
Two failure modes reported in #17:
'{"prompt":"don'\'t"}'— escaped apostrophes causedUnclosed quoteerrors because escape processing was active inside single quotes"{\"prompt\":\"line1\\nline2\"}"— backslash was stripped during escape processing, corrupting JSON escape sequencesFix
current += ch + next) instead of stripping the backslashTests
Added 3 new tests to
test/parser.test.ts:--args-jsonwith escaped JSON in double quotesAll 50 existing tests continue to pass (the 1 pre-existing failure in
two approve gates can be resumed sequentiallyis unrelated).Fixes #17