Skip to content

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

@dannylin108

Description

@dannylin108

Problem

parsePipeline/tokenizeCommand mishandles escapes inside quoted arguments, which can corrupt --args-json payloads before they reach command handlers.

Two user-visible failure modes:

  1. Backslashes inside double-quoted args are treated too aggressively, so JSON escape content can be altered.
  2. Escaped apostrophes (\') inside single-quoted args are treated as quote terminators, causing parse failures.

Reproduction

A) Escaped apostrophe in single-quoted JSON

Input:

openclaw.invoke --args-json '{"prompt":"don\'t"}'

Observed (before fix): parser can throw Unclosed quote.

Expected: tokenization should preserve the literal apostrophe and pass valid JSON through.

B) Escapes in double-quoted JSON

Input pattern:

openclaw.invoke --tool llm-task --action json --args-json "{\"prompt\":\"line1\\nline2\"}"

Observed (before fix): quoted-token parsing can alter escape sequences, changing payload semantics and risking downstream JSON handling issues.

Expected: escape sequences required by JSON should survive tokenization unchanged (except shell-like quote escaping).

Impact

This breaks existing pipelines that pass prompt-rich JSON through --args-json, especially payloads containing apostrophes and escaped characters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions