Bugfix: Properly handle workspace names with double quotes (+test) (Thanks kvapen)

This commit is contained in:
Michael Stapelberg
2012-01-30 16:55:06 +00:00
parent ed2bcc15e3
commit 2f8d3d3390
3 changed files with 53 additions and 4 deletions

View File

@ -274,7 +274,18 @@ char *parse_command(const char *input) {
}
if (walk != beginning) {
char *str = scalloc(walk-beginning + 1);
strncpy(str, beginning, walk-beginning);
/* We copy manually to handle escaping of characters. */
int inpos, outpos;
for (inpos = 0, outpos = 0;
inpos < (walk-beginning);
inpos++, outpos++) {
/* We only handle escaped double quotes to not break
* backwards compatibility with people using \w in
* regular expressions etc. */
if (beginning[inpos] == '\\' && beginning[inpos+1] == '"')
inpos++;
str[outpos] = beginning[inpos];
}
if (token->identifier)
push_string(token->identifier, str);
DLOG("str is \"%s\"\n", str);