[winpr,cmdline] fix unquoting of value
Comma separated lists of form 'a,b,\"b,c,d\"' were not correctly parsed as the trailing quote was not consumed.
This commit is contained in:
parent
5a6a2a17b1
commit
184e006ce5
@ -665,6 +665,7 @@ char** CommandLineParseCommaSeparatedValuesEx(const char* name, const char* list
|
|||||||
char* unquoted = NULL;
|
char* unquoted = NULL;
|
||||||
BOOL fullquoted = FALSE;
|
BOOL fullquoted = FALSE;
|
||||||
|
|
||||||
|
BOOL success = FALSE;
|
||||||
if (count == NULL)
|
if (count == NULL)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@ -718,6 +719,7 @@ char** CommandLineParseCommaSeparatedValuesEx(const char* name, const char* list
|
|||||||
p[0] = dst;
|
p[0] = dst;
|
||||||
sprintf_s(dst, clen + 1, "%s", name);
|
sprintf_s(dst, clen + 1, "%s", name);
|
||||||
*count = 1;
|
*count = 1;
|
||||||
|
success = TRUE;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -768,8 +770,6 @@ char** CommandLineParseCommaSeparatedValuesEx(const char* name, const char* list
|
|||||||
if (lastQuote != quote)
|
if (lastQuote != quote)
|
||||||
{
|
{
|
||||||
WLog_ERR(TAG, "invalid argument (quote mismatch) '%s'", list);
|
WLog_ERR(TAG, "invalid argument (quote mismatch) '%s'", list);
|
||||||
free(p);
|
|
||||||
p = NULL;
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
else if (lastQuote != 0)
|
else if (lastQuote != 0)
|
||||||
@ -779,11 +779,25 @@ char** CommandLineParseCommaSeparatedValuesEx(const char* name, const char* list
|
|||||||
|
|
||||||
str = comma + 1;
|
str = comma + 1;
|
||||||
}
|
}
|
||||||
|
else if (quote)
|
||||||
|
{
|
||||||
|
char* end = strrchr(ptr, '"');
|
||||||
|
if (!end)
|
||||||
|
goto fail;
|
||||||
|
*end = '\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*count = nArgs;
|
*count = nArgs;
|
||||||
|
success = TRUE;
|
||||||
fail:
|
fail:
|
||||||
free(copy);
|
free(copy);
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
*count = 0;
|
||||||
|
free(p);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user