X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcommands_parser.c;h=fa4c2360101513e4796490c9720ff9b63533915f;hb=93adcf8bdcc09ab78ed265b3392900be552596fa;hp=f325a048afc6ebf6859ee81347fafd7c8dc4de28;hpb=3c5df50c54ab6451098c2175a21470312952000e;p=i3%2Fi3 diff --git a/src/commands_parser.c b/src/commands_parser.c index f325a048..fa4c2360 100644 --- a/src/commands_parser.c +++ b/src/commands_parser.c @@ -216,8 +216,9 @@ char *parse_string(const char **walk, bool as_word) { if (**walk == '"') { beginning++; (*walk)++; - while (**walk != '\0' && (**walk != '"' || *(*walk - 1) == '\\')) - (*walk)++; + for (; **walk != '\0' && **walk != '"'; (*walk)++) + if (**walk == '\\' && *(*walk + 1) != '\0') + (*walk)++; } else { if (!as_word) { /* For a string (starting with 's'), the delimiters are @@ -248,10 +249,10 @@ char *parse_string(const char **walk, bool as_word) { 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] == '"') + /* We only handle escaped double quotes and backslashes to not break + * backwards compatibility with people using \w in regular expressions + * etc. */ + if (beginning[inpos] == '\\' && (beginning[inpos + 1] == '"' || beginning[inpos + 1] == '\\')) inpos++; str[outpos] = beginning[inpos]; }