Repository navigation
Conversation
noahc3#45 wraps an argument in quotes when it contains a space. CreateProcess re-parses the Arguments string with the CommandLineToArgvW rules, and under those rules that is not enough: C:\My Folder\ -> "C:\My Folder\" the trailing backslash escapes the closing quote and the next argument is swallowed into it say "hi" there -> the embedded quotes end the quoting early (empty) -> the argument disappears tab-separated -> not quoted at all, split in two Quote per the rules instead: double the backslashes that precede a quote or the closing quote, escape embedded quotes, and quote any argument that is empty or contains whitespace or a quote. net48 has no ProcessStartInfo.ArgumentList, which would otherwise do this. Checked by round-tripping generated command lines back through CommandLineToArgvW: plain paths, paths with spaces, several such paths in one line, a trailing backslash, an embedded quote, doubled backslashes, and a mixture all parse back to the original argv.
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.
#45 wraps an argument in quotes when it contains a space.
CreateProcessre-parses the string by theCommandLineToArgvWrules, under which that isn't enough:C:\My Folder\"C:\My Folder\"say "hi" there"say "hi" there"a<TAB>bThis quotes per the rules instead: backslashes before a quote or before the closing quote are doubled, embedded quotes are escaped, and an argument is quoted if it's empty or contains whitespace or a quote. net48 has no
ProcessStartInfo.ArgumentList, which would otherwise do this.Checked by round-tripping the generated command lines back through
CommandLineToArgvW: plain paths, paths with spaces, several such paths in one line, a trailing backslash, an embedded quote, doubled backslashes, and a mixture all parse back to the original arguments.