-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quote editor.path
argument
#112
Conversation
The `editor.path` string can contain spaces, e.g. `/Applications/Visual Studio Code.app/...`. This string is passed to `execa()`, which attempts to execute it as a command in the user's shell. On some systems, this string must be quoted, or else the shell will interpret the substring until the first space as the command, and either error or execute the wrong thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From https://github.com/sindresorhus/execa/tree/v5.1.1#execacommandcommand-options:
If the file or an argument contains spaces, they must be escaped with backslashes. This matters especially if command is not a constant but a variable, for example with __dirname or process.cwd(). Except for spaces, no escaping/quoting is needed.
https://github.com/MetaMask/create-release-branch/actions/runs/7041542167/job/19164270553
@legobeat hmm, that's interesting. The weirdness here is that this has not been a problem for anyone who has used this tool, except myself as described above. Specifically, the error I got was:
I already tried my change locally and it fixes the error. However, according to this source, we should probably single-quote paths:
I'm discussing with @mcmire where we're going to introduce quoting / escaping. I'm leaving this in draft until it's ready for another round of reviews. |
I'd wager that either quoting with single-quote or shell-escaping (with caveats - beware of shell-injection here) will work for arguments while escaping should be correct for the command itself? |
@legobeat, single-quoting seems to work fine on my system:
And this would be consistent with this source:
|
Why not support single-quotes? |
@legobeat @rekmarks we currently use |
Just heads up that EDIT: Looks like it would actually be reasonable to stay on CommonJS and utilize dynamic imports. The mocking and spying in the tests would need to be rewritten somewhat to accommodate (or does Jest support running the tests as ESM while the package is otherwise CommonJS? 🤔 ) |
Closing in favor of #121. |
This PR updates `execa` to `^8.0.1`. Since `execa@>=6.0.0` is ESM-only and `jest` only has experimental ESM support (jestjs/jest#10976), this required switching from `ts-jest` to `babel-jest`. To minimize dependency transpilation, the ESM packages that are necessary to transpile are enumerated in `jest.config.js`. This version of `execa` includes [automatic escaping of shell arguments](https://github.com/sindresorhus/execa/tree/v8.0.1#execafile-arguments-options), which was the entire point of #112, #113, and this PR. The state of ESM support in the Node.js ecosystem is absolutely horrible, and I would not recommend further migrations for the time being. We should continue to dual-release our packages and avoid ESM-only dependencies until the ecosystem has matured. For details see the above `jest` issue and nodejs/node#37648.
The
editor.path
string can contain spaces, e.g./Applications/Visual Studio Code.app/...
. This string is passed toexeca()
, which attempts to execute it as a command in the user's shell. On some systems, this string must be quoted, or else the shell will interpret the substring until the first space as the command, and either error or execute the wrong thing.