-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
Handle URL and paths escaping in Windows #146
Conversation
@sindresorhus Need me to do something else? Can we get a new version with this fix? |
Sorry for the slow response. I have a lot to catch up on after the summer. |
Does this also fix the problem in #98? |
Hello @Stanzilla, yes it does! Since I'm here: Hey @sindresorhus, when you have some spare time, this is ready for another review ;) |
@herberttn Thanks for your awesome work on this 🙌 |
🎉 |
Maybe need some test for urls contains '%' (e.g. https://cn.bing.com/search?q=%2520 https://cn.bing.com/search?q=%E5%A5%BD). I think |
This fixes an old problem that has been widely reported but haven't had a simple and concrete solution yet. This is my attempt on making it happen 🙃
To sum up the problem: on windows, ampersand (
&
) characters were being escaped with caret (^
) characters due to windows's cmd interpreting them as a command would break (as in command not found) or would forward a partial argument only (as in URLs with query arguments that contain spaces).The solution: JavaScript's standard
encodeURI
function would solve the problem for URLs, but not for file paths (especially on windows). So we leverage the fact that window'scmd
interprets a double-quoted argument as a plain text argument just by quoting it (like Node already does). For that to be consistent we need to disable Node's default quoting and escaping behavior (which is conditional) with its ownwindowsVerbatimArguments
flag, and do it ourselves.Tested in Windows with both Google Chrome and Internet Explorer, using query strings, spaces, pipes, fragments and multiple combinations of all of them.
childProcess.spawn
shell
option on Windows and fix the quote issue #115: Shell option is not needed since windowsVerbatimArguments is now used explicitly|
on windows #98: URL with pipe charactersIssueHunt Summary
Referenced issues
This pull request has been submitted to:
childProcess.spawn
shell
option on Windows and fix the quote issueIssueHunt has been backed by the following sponsors. Become a sponsor