Skip to content

🐛 fix(attach): keep literal backslashes inside double quotes in splitShellWords - #389

Merged
hivecommons-hive[bot] merged 2 commits into
mainfrom
scanner/fix-387
Oct 27, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
mainfrom
scanner/fix-387

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

splitShellWords dropped every backslash outside single quotes, including inside double quotes where POSIX treats it as literal unless followed by $, backtick, ", \ or newline. Inside double quotes the backslash is now kept for ordinary characters; behaviour outside quotes is unchanged. Added tests next to the existing escaping test and a changelog fragment.

Closes #387

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

…ellWords

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 27, 2026
@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kellyaa for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 27, 2026
@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 27, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending — sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read splitShellWords in full at 8721552 (src/attach.ts:67-116) and its caller buildCliCommand (src/attach.ts:118). Looks correct to me.

  • The escape set '$"\\n' (src/attach.ts:76) is exactly POSIX 2.2.3's: before those characters the backslash is still dropped, before anything else it is kept. Outside quotes the branch is skipped by quote === '"', so existing behaviour is unchanged; inside single quotes ` never reaches this branch (src/attach.ts:81).
  • Trailing \ inside an open " still appends the backslash and then throws the existing Unterminated quote error (src/attach.ts:109-113), so no new silent path.
  • Built and ran test/attach-orchestration.test.js locally: 44/44 pass.

Only note (pre-existing, not from this change): \+newline inside double quotes yields a literal newline where POSIX would join lines; the unquoted path already behaves that way, so nothing to do here.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed — no findings from this perspective.

— hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Hive filed review findings that do not block this PR as backlog items:

Cap: 10 backlog item(s) per PR per day.

@hivecommons-hive hivecommons-hive Bot added stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Oct 27, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

stage 060-reviewed → 050-review-pending: pending: head pushed 1m29s ago (< min_head_age)

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed — no findings from this perspective.

— hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed — no findings from this perspective.

— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks correct to me.

Read splitShellWords in full at fafa17c (src/attach.ts:67-112) plus the callers (src/attach.ts:46,117,130,226,357,445, src/cli.ts:249). The one-line change at src/attach.ts:76 only fires on the escaping branch when quote === '"', so unquoted (a\ b) and single-quoted paths are untouched, and \", \\, \`, \$ inside double quotes still collapse as before — matching the POSIX rule the issue (#387) spells out. The trailing-backslash handling at :103-106 is unaffected (a dangling \ inside "…" still ends in the unterminated-quote throw).

Ran node --test test/attach-orchestration.test.js on the PR head: 44/44 pass, including the five new cases. verify, test (22/24/26) and DCO are green; the only pending check is tide.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read splitShellWords in full at fafa17c plus all nine callers (src/attach.ts:46,117,130,226,357,380,445, src/cli.ts:249). Looks correct to me.

  • src/attach.ts:76 only fires when quote === '"', so unquoted \ / \" handling (test/attach-orchestration.test.js:541) is untouched — confirmed by the existing test still passing.
  • Inside "…", \" still reaches the escaping branch before the char === quote check at :93, so the quote is not closed early; \\, \` and \$ collapse to one char as POSIX requires.
  • The rgBin caller at :46 regex-escapes each word after splitting, so a now-preserved backslash in a quoted path is escaped rather than passed raw.

Ran node --test test/attach-orchestration.test.js at the PR head: both splitShellWords tests pass, npm run build clean. Matches the behaviour #387 asked for (per #387: keep the backslash unless the next char is one of $ " `).

Not blocking, pre-existing: \<newline> inside double quotes yields a literal newline rather than being removed as a line continuation; nothing in the issue scope depends on it.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed — no findings from this perspective.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit e0836cf into main Oct 27, 2026
9 of 10 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-387 branch October 27, 2026 10:40
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#389fafa17c` sha256:c8fe107876f04816fefc341210e2d59324a49600aa37e59bf2099d8082673649 — download from the dashboard or `hivectl review evidence #389`.

@github-actions

Copy link
Copy Markdown

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] attach: splitShellWords strips backslashes before ordinary characters inside double quotes

0 participants