Skip to content

fix: escape single quotes in test-case input for POSIX shells - #1032

Open
sivaharish31 wants to merge 1 commit into
LeetCode-OpenSource:masterfrom
sivaharish31:fix/test-input-single-quote-escaping
Open

sivaharish31 wants to merge 1 commit into
LeetCode-OpenSource:masterfrom
sivaharish31:fix/test-input-single-quote-escaping

Conversation

@sivaharish31

Copy link
Copy Markdown

Summary

  • Escape embedded single quotes when constructing POSIX shell commands for custom test input.
  • Correct single-quote escaping in the PowerShell branch.
  • Add standalone regression checks for shell argument preservation.

Testing

  • node test/verify-quoting.js — 26/26 cases passed across Git Bash and Windows CMD, with exact argument comparisons.
  • npx tsc -p ./ --skipLibCheck — passed.
  • npx tslint --project tsconfig.json -e 'src/*.d.ts' -t verbose — passed.

Limitations

  • The regression script mirrors the production quoting logic rather than directly invoking the private parseTestString() function, because the module requires the VS Code extension host.
  • Bash was tested through Git Bash on Windows; native Linux/macOS were not tested.
  • CMD was tested on Windows.
  • The PowerShell branch follows documented quoting conventions but was not live-tested.

Fixes #1031

The parseTestString() function wraps custom test input in single quotes
for Bash/WSL but does not escape embedded single quotes. An input like
it's produces a shell parse error, and ['a','b'] silently becomes [a,b]
because Bash strips the inner quotes.

Apply the standard POSIX '\'' escape pattern for the Bash/WSL branch
and the '' doubling convention for the PowerShell branch.

Add a standalone regression test verifying 13 inputs through actual
Bash and CMD shell execution.

Fixes LeetCode-OpenSource#1031
@sivaharish31
sivaharish31 force-pushed the fix/test-input-single-quote-escaping branch from 1d6c06b to ec22895 Compare October 22, 2026 07:07

This branch has not been deployed

No deployments
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.

parseTestString does not escape single quotes in custom test cases

1 participant