From: Michael Stapelberg Date: Fri, 10 Feb 2012 19:49:38 +0000 (+0000) Subject: Bugfix: Correctly handle missing ending double quotes (+test) (Thanks mxf) X-Git-Tag: 4.2~85 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=82247fd0abe30dfa37f7101190cceb146665c9e8;p=i3%2Fi3 Bugfix: Correctly handle missing ending double quotes (+test) (Thanks mxf) --- diff --git a/src/commands_parser.c b/src/commands_parser.c index 1b030102..cdfafee2 100644 --- a/src/commands_parser.c +++ b/src/commands_parser.c @@ -249,7 +249,7 @@ char *parse_command(const char *input) { if (*walk == '"') { beginning++; walk++; - while (*walk != '"' || *(walk-1) == '\\') + while (*walk != '\0' && (*walk != '"' || *(walk-1) == '\\')) walk++; } else { if (token->name[0] == 's') { diff --git a/testcases/t/187-commands-parser.t b/testcases/t/187-commands-parser.t index ca81e2f6..f019c366 100644 --- a/testcases/t/187-commands-parser.t +++ b/testcases/t/187-commands-parser.t @@ -165,6 +165,10 @@ is(parser_calls('workspace "foo"'), 'cmd_workspace_name(foo)', 'Command with simple double quotes ok'); +is(parser_calls('workspace "foo'), + 'cmd_workspace_name(foo)', + 'Command without ending double quotes ok'); + is(parser_calls('workspace "foo \"bar"'), 'cmd_workspace_name(foo "bar)', 'Command with escaped double quotes ok');