From 82247fd0abe30dfa37f7101190cceb146665c9e8 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 10 Feb 2012 19:49:38 +0000 Subject: [PATCH] Bugfix: Correctly handle missing ending double quotes (+test) (Thanks mxf) --- src/commands_parser.c | 2 +- testcases/t/187-commands-parser.t | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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'); -- 2.39.5