From ba774317ac7d3e67fdb9ed81663264d38859df59 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Thu, 18 Dec 2014 17:51:38 -0500 Subject: Treat a trailing backslash as an error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit a2a5291b3f5 changed the parser to reject unfinished quoted strings. Unfortunately it introduced an error where a trailing backslash would case an infinite loop. Of course this must fixed, but the question is what to to instead. Allowing trailing backslashes and treating them as normal characters would be one option, but this seems suboptimal. First, there would be inconsistency between handling of quoting and of backslashes. Second, a trailing backslash is most likely an error, at it seems better to point it out to the user than to try to continue. Updated rules: ExecStart=/bin/echo \\ → OK, prints a backslash ExecStart=/bin/echo \ → error ExecStart=/bin/echo "x → error ExecStart=/bin/echo "x"y → error --- src/test/test-strv.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/test/test-strv.c') diff --git a/src/test/test-strv.c b/src/test/test-strv.c index 0b78086ea9..f343eab7c6 100644 --- a/src/test/test-strv.c +++ b/src/test/test-strv.c @@ -520,6 +520,10 @@ int main(int argc, char *argv[]) { test_strv_unquote(" \"x'\" ", STRV_MAKE("x'")); test_strv_unquote("a '--b=c \"d e\"'", STRV_MAKE("a", "--b=c \"d e\"")); + /* trailing backslashes */ + test_strv_unquote(" x\\\\", STRV_MAKE("x\\")); + test_invalid_unquote(" x\\"); + test_invalid_unquote("a --b='c \"d e\"''"); test_invalid_unquote("a --b='c \"d e\" '\""); test_invalid_unquote("a --b='c \"d e\"garbage"); -- cgit v1.2.3-54-g00ecf