Merge pull request #11858 from Pollux42/fix-parse-quote

Fix quote parsing
This commit is contained in:
akallabeth
2025-09-12 20:42:20 +02:00
committed by GitHub
2 changed files with 14 additions and 2 deletions

View File

@@ -244,8 +244,13 @@ LPSTR* CommandLineToArgvA(LPCSTR lpCmdLine, int* pNumArgs)
if (*p != '"')
WLog_ERR(TAG, "parsing error: uneven number of unescaped double quotes!");
if (p[0] && p[1])
p += 1 + strcspn(&p[1], " \t\0");
if (*p)
{
p++;
if (*p)
p += strcspn(p, " \t\0");
}
pArgs[numArgs++] = pOutput;

View File

@@ -31,6 +31,10 @@ static const char* test_args_line_7 = "app.exe a\\\\\\\\\"b c\" d e f\\\\\\\\\"g
static const char* test_args_list_7[] = { "app.exe", "a\\\\b c", "d", "e", "f\\\\g h", "i", "j" };
static const char* test_args_line_8 = "app.exe arg1 \"arg2\"";
static const char* test_args_list_8[] = { "app.exe", "arg1", "arg2" };
static BOOL test_command_line_parsing_case(const char* line, const char** list, size_t expect)
{
BOOL rc = FALSE;
@@ -104,6 +108,9 @@ int TestThreadCommandLineToArgv(int argc, char* argv[])
if (!test_command_line_parsing_case(test_args_line_7, test_args_list_7,
ARRAYSIZE(test_args_list_7)))
return -1;
if (!test_command_line_parsing_case(test_args_line_8, test_args_list_8,
ARRAYSIZE(test_args_list_8)))
return -1;
return 0;
}