Skip to content

fix(parser): preserve JSON escapes in quoted args#16

Open
dannylin108 wants to merge 2 commits intoopenclaw:mainfrom
dannylin108:fix/parser-json-escape-handling
Open

fix(parser): preserve JSON escapes in quoted args#16
dannylin108 wants to merge 2 commits intoopenclaw:mainfrom
dannylin108:fix/parser-json-escape-handling

Conversation

@dannylin108
Copy link

@dannylin108 dannylin108 commented Feb 18, 2026

Summary

  • fix tokenizeCommand so quoted parsing does not strip arbitrary backslashes
  • preserve escape sequences like \\n / \\t in double-quoted tokens
  • keep single-quoted content literal
  • add parser regression tests for --args-json handling

Why

--args-json payloads (especially prompt-rich JSON) could be corrupted during tokenization because backslashes were always consumed in quoted mode. This broke valid JSON before command handlers parsed it.

Validation

  • pnpm build
  • node --test dist/test/parser.test.js

fix #17

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb665341b9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +64 to +66
if (ch === quote) {
quote = null;
continue;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve escaped apostrophes in single-quoted args

The new single-quote branch closes on every ' character, so inputs that rely on \' now break with Unclosed quote instead of producing a literal apostrophe. For example, --args-json '{"prompt":"don\'t"}' (a common pattern when wrapping JSON in single quotes) parsed before this change but now fails, which can break prompt/JSON payloads containing apostrophes in existing pipelines.

Useful? React with 👍 / 👎.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@dannylin108 dannylin108 force-pushed the fix/parser-json-escape-handling branch from e2f905a to efc6895 Compare February 18, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parser mishandles escaped characters in quoted args, breaking --args-json payloads

1 participant