libpkgconf: tuple: tighten quoting logic a bit

closes #12
pull/188/head
William Pitcock 2019-03-23 22:33:55 -05:00
parent 3afd14c49e
commit 662957ca7d
2 changed files with 8 additions and 5 deletions

2
NEWS
View File

@ -12,6 +12,8 @@ Changes from 1.6.0 to 1.6.1:
paths.
- Use POSIX realpath(3) instead of readlink() for deduplicating the
search path. Use _fullpath() on Windows for the same purpose.
- The dequoting logic for tuples has been improved to ensure that
quotes *inside* a value remain quoted when necessary.
Changes from 1.5.4 to 1.6.0:
----------------------------

View File

@ -144,17 +144,18 @@ dequote(const char *value)
const char *i;
char quote = 0;
if (*value == '\'' || *value == '"')
quote = *value;
for (i = value; *i != '\0'; i++)
{
if (!quote && (*i == '\'' || *i == '"'))
quote = *i;
else if (*i != quote)
*bptr++ = *i;
else if (*i == '\\' && *(i + 1) == quote)
if (*i == '\\' && quote && *(i + 1) == quote)
{
i++;
*bptr++ = *i;
}
else if (*i != quote)
*bptr++ = *i;
}
return buf;