Skip to content

fix: keep apostrophes and inline = values when parsing arguments - #816

Open
azixxxxx wants to merge 1 commit into
openai:mainfrom
azixxxxx:fix/args-apostrophes-inline-values
Open

azixxxxx wants to merge 1 commit into
openai:mainfrom
azixxxxx:fix/args-apostrophes-inline-values

Conversation

@azixxxxx

@azixxxxx azixxxxx commented Oct 14, 2026 •

Copy link
Copy Markdown

Summary

Slash commands pass $ARGUMENTS to the companion as one string, which splitRawArgumentString splits into tokens. It treated every ' or " as the start of a quoted string, so an apostrophe in ordinary text swallowed the rest of the line:

splitRawArgumentString("fix the user's bug --model spark")
// before: ["fix", "the", "users bug --model spark"]   (--model ends up in the prompt)
// after:  ["fix", "the", "user's", "bug", "--model", "spark"]

Separately, parseArgs split --key=value with split("=", 2), which drops everything after a second = (#807): --prompt-file=notes=v2.txt became notes.

Changes

  • Quotes group words only when they open a token (or follow =, as in --prompt-file="my notes.txt") and only when a matching closing quote exists. Other quotes, like apostrophes inside words, are literal.
  • A backslash only escapes quotes, whitespace, and backslashes. Elsewhere it stays, so text such as a regex (\d+) or a Windows path keeps its backslashes.
  • A quoted empty string ("") stays an empty argument; before, it was dropped.
  • --key=value splits at the first =.

Tests

New tests/args.test.mjs covers apostrophes, quoted groups, empty quoted arguments, = values, backslashes, and whitespace. All five tests fail on main and pass with this change. npm test (96 tests) and npm run build pass.

Fixes #807

🤖 Generated with Claude Code

splitRawArgumentString treated every quote character as the start of a
quoted string, so an apostrophe in ordinary text ("fix the user's bug
--background") swallowed the rest of the line: the words merged into one
token and flags after it, such as --background or --model, became prompt
text. parseArgs split --key=value with split("=", 2), which drops
everything after a second "=" (openai#807).

- Quotes group words only when they open a token or follow "=", and only
  when a matching closing quote exists; other quotes are literal.
- A backslash only escapes quotes, whitespace, and backslashes, so text
  such as a regex (\d+) or a Windows path keeps its backslashes.
- --key=value splits at the first "=".

Fixes openai#807

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@azixxxxx
azixxxxx requested a review from a team October 14, 2026 19:20
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T19:26:40.726477Z 0d4845f PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: 0d4845fe53

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +116 to +118
const closing = text.indexOf(character, index + 1);
if (closing !== -1) {
current += text.slice(index + 1, closing);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor escapes while scanning quoted tokens

When one-string slash-command arguments contain an escaped delimiter inside a quoted group (for example, a prompt containing "hello \"world\" today"), indexOf treats the escaped quote as the closing delimiter and the sliced contents bypass the ESCAPABLE handling. splitRawArgumentString consequently corrupts and splits the quoted prompt or option value instead of preserving hello "world" today as one token; scan for an unescaped matching quote and process escapes within the quoted range.

Useful? React with 👍 / 👎.

Edo771977 added a commit to Edo771977/codex-plugin-cc that referenced this pull request Oct 17, 2026
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.

parseArgs cuts an inline --key=value at the second "="

1 participant