Bug 1853920 - [2/2] quote empty strings in Windows command lines r=win-reviewers,gstoll
Quote empty arguments in command lines. Add appropriate tests. Differential Revision: https://phabricator.services.mozilla.com/D191128
This commit is contained in:
@@ -362,8 +362,12 @@ inline size_t CopyArgImpl_(wchar_t* d, const wchar_t* s) {
|
||||
};
|
||||
|
||||
bool hasDoubleQuote = wcschr(s, L'"') != nullptr;
|
||||
// Only add doublequotes if the string contains a space or a tab
|
||||
bool addDoubleQuotes = wcspbrk(s, kCommandLineDelimiter) != nullptr;
|
||||
// Only add doublequotes if...
|
||||
bool addDoubleQuotes =
|
||||
// ... the string is empty, or...
|
||||
*s == '\0' ||
|
||||
// ... the string contains a space or a tab.
|
||||
wcspbrk(s, kCommandLineDelimiter) != nullptr;
|
||||
|
||||
if (addDoubleQuotes) {
|
||||
appendChar('"');
|
||||
|
||||
@@ -92,3 +92,12 @@ output_24=a:\b "c\アルファ オメガ\d"
|
||||
|
||||
input_25=アルファ オメガ
|
||||
output_25=アルファ オメガ
|
||||
|
||||
input_26=arg1 "" arg3
|
||||
output_26=arg1 "" arg3
|
||||
|
||||
input_27=""""
|
||||
output_27=""""
|
||||
|
||||
input_28=""" a """
|
||||
output_28=""" a """
|
||||
|
||||
Reference in New Issue
Block a user