Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates PowerShell argument quoting in build/util.cjs and src/util.ts to handle special single quote characters (U+2018, U+2019, U+201A, and U+201B) by doubling them, and adds corresponding unit tests. The review feedback suggests optimizing the replacement logic in src/util.ts by using a regex capture group and a replacement string instead of a callback function to improve performance.
gargarnav
force-pushed
the
fix/quote-powershell-unicode-quotes
branch
2 times, most recently
from
October 17, 2026 10:20
b92f0d5 to
9f2994a
Compare
PowerShell treats U+2018, U+2019, U+201A and U+201B as single-quote characters, so a value containing one of them ended the quoted string early and the rest of the value was parsed as PowerShell code. Double all of them, as is done for the ASCII apostrophe, and add tests.
gargarnav
force-pushed
the
fix/quote-powershell-unicode-quotes
branch
from
October 17, 2026 10:21
9f2994a to
02c638d
Compare
Author
|
Addressed the review feedback and re-signed the commit. Could a maintainer approve the pending workflows when you get a chance? Thanks! |
6 of 7 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: suggests an improvement (hardening of
quotePowerShell)Why
quotePowerShell()wraps a value in ASCII single quotes and doubles only the ASCII apostrophe. PowerShell also treats U+2018, U+2019, U+201A and U+201B as single-quote characters, so a value containing one of them closes the string early and the remainder is parsed as PowerShell code.With
usePwsh()(or$.quote = quotePowerShell) and untrusted input:I confirmed the before behavior on PowerShell 7.6.7 (macOS) for U+2018 and U+2019 by running the emitted command shape (
<cmd>; exit $LastExitCode) directly. U+201A and U+201B are listed as single quotes in PowerShell's quoting rules and are covered by the fix.Change
src/util.ts:arg.replace(/['‘’‚‛]/g, (c) => c + c), plus a test for the four characters and the regeneratedbuild/util.cjs.Checks
npm run build; onlybuild/util.cjschanged meaningfully (other generated noise reverted)test/util.test.jspasses; the full unit run has the same pre-existing failures with and without this change in my environment (thenable args, exports chalk level, log/fetch tests)