qwen-code/packages/core
chinesepowered 945ea1d032
fix(core): track quotes inside a command substitution in splitCommands (#7870)
Quote tracking was gated on `substitutionDepth === 0`, so quotes inside a
`$(...)` body were invisible to the parser. A `)` inside those quotes then
closed the substitution early, and the body's own closing quote -- now
seen at depth 0 -- flipped the parser into "in quote" state, which
swallowed every separator to the end of the line.

  splitCommands(`echo $(echo ')') ; rm -rf /tmp/pwned`)
    -> ["echo $(echo ')') ; rm -rf /tmp/pwned"]     one segment
  getCommandRoots(same)
    -> ["echo"]                                     rm is gone

The trailing command did not merely stay joined to the first, it vanished
from the roots. shell.ts uses these segments to decide which sub-commands
need confirmation, and to locate the git commit / gh pr create segment for
attribution, which silently no-ops on a mis-split.

Gating the closing paren on the surrounding quote state is not enough,
because `"$(...)"` puts a double quote around the whole substitution and
that quote belongs to the outer command. Save the enclosing quote state on
`$(` and restore it on the matching `)`, so each body is quoted
independently of its surroundings.

splitCommands had no direct unit tests; this adds them, including the
nesting and quoting shapes that must keep behaving as they do.
2026-07-28 12:05:07 +00:00
..
scripts Fix: Improve ripgrep binary detection and cross-platform compatibility (#1060) 2025-11-18 19:38:30 +08:00
src fix(core): track quotes inside a command substitution in splitCommands (#7870) 2026-07-28 12:05:07 +00:00
vendor feat test tool permissions 2026-03-10 16:30:22 +08:00
index.ts fix: Remove remaining ClearcutLogger export from packages/core/index.ts 2026-02-01 14:52:14 +08:00
package.json feat(core): add full-resolution image zoom tool (#7809) 2026-07-27 23:40:26 +00:00
test-setup.ts feat(memory): managed auto-memory and auto-dream system (#3087) 2026-04-16 20:05:45 +08:00
tsconfig.json fix: upgrade @lydell/node-pty to 1.2.0-beta.10 to fix PTY FD leak 2026-04-01 07:55:56 +08:00
vitest.config.ts test: raise timeout ceiling for I/O-bound tests flaky under CI contention (#7230) 2026-07-19 12:03:48 +00:00