Core/Commands: Handle "" as empty string argument

Fixes #11548
This commit is contained in:
jackpoz
2014-03-29 21:07:46 +01:00
parent 0b615ec159
commit 4cffd2e707

View File

@@ -1180,10 +1180,32 @@ char* ChatHandler::extractQuotedArg(char* args)
return strtok(args+1, "\"");
else
{
char* space = strtok(args, "\"");
if (!space)
// skip spaces
while (*args == ' ')
{
args += 1;
continue;
}
// return NULL if we reached the end of the string
if (!*args)
return NULL;
// since we skipped all spaces, we expect another token now
if (*args == '"')
{
// return an empty string if there are 2 "" in a row.
// strtok doesn't handle this case
if (*(args + 1) == '"')
{
strtok(args, " ");
return "";
}
else
return strtok(args + 1, "\"");
}
else
return NULL;
return strtok(NULL, "\"");
}
}