diff options
author | Tobias Brunner <tobias@strongswan.org> | 2015-06-08 17:49:02 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2015-07-28 13:27:32 +0200 |
commit | 019ebdafae94f322ddab4ccbd0d90140bc2f26e1 (patch) | |
tree | 0d56dcf7ce5262f266932ce7b7a9c162bc3eafd0 /src | |
parent | 764960e8b95576b8ffe2e43d41539e4de735682e (diff) | |
download | strongswan-019ebdafae94f322ddab4ccbd0d90140bc2f26e1.tar.bz2 strongswan-019ebdafae94f322ddab4ccbd0d90140bc2f26e1.tar.xz |
starter: Add support for multi-line strings in ipsec.conf
Diffstat (limited to 'src')
-rw-r--r-- | src/starter/parser/lexer.l | 9 | ||||
-rw-r--r-- | src/starter/parser/parser.y | 2 | ||||
-rw-r--r-- | src/starter/tests/suites/test_parser.c | 3 |
3 files changed, 6 insertions, 8 deletions
diff --git a/src/starter/parser/lexer.l b/src/starter/parser/lexer.l index d9f469c36..f70658e68 100644 --- a/src/starter/parser/lexer.l +++ b/src/starter/parser/lexer.l @@ -123,16 +123,11 @@ static void include_files(parser_helper_t *ctx); <str>{ "\"" | <<EOF>> | - \n | \\ { if (!streq(yytext, "\"")) { - if (streq(yytext, "\n")) - { /* put the newline back to fix the line numbers */ - unput('\n'); - yy_set_bol(0); - } PARSER_DBG1(yyextra, "unterminated string detected"); + return STRING_ERROR; } if (yy_top_state(yyscanner) == inc) { /* string include */ @@ -152,7 +147,7 @@ static void include_files(parser_helper_t *ctx); \\t yyextra->string_add(yyextra, "\t"); \\\r?\n /* merge lines that end with EOL characters */ \\. yyextra->string_add(yyextra, yytext+1); - [^\\\n"]+ { + [^\\"]+ { yyextra->string_add(yyextra, yytext); } } diff --git a/src/starter/parser/parser.y b/src/starter/parser/parser.y index 54dedc12b..0b2b3b09f 100644 --- a/src/starter/parser/parser.y +++ b/src/starter/parser/parser.y @@ -73,7 +73,7 @@ static int yylex(YYSTYPE *lvalp, parser_helper_t *ctx) conf_parser_section_t t; } %token <s> STRING -%token EQ SPACES NEWLINE CONFIG_SETUP CONN CA +%token EQ SPACES NEWLINE CONFIG_SETUP CONN CA STRING_ERROR /* ...and other symbols */ %type <t> section_type diff --git a/src/starter/tests/suites/test_parser.c b/src/starter/tests/suites/test_parser.c index 26a41ba55..4ae7b22fa 100644 --- a/src/starter/tests/suites/test_parser.c +++ b/src/starter/tests/suites/test_parser.c @@ -328,6 +328,9 @@ static struct { { TRUE, "conn foo\n\tkey=val ue", "foo", "val ue" }, { TRUE, "conn foo\n\tkey=\"val ue\"", "foo", "val ue" }, { TRUE, "conn foo\n\tkey=\"val\\nue\"", "foo", "val\nue" }, + { TRUE, "conn foo\n\tkey=\"val\nue\"", "foo", "val\nue" }, + { TRUE, "conn foo\n\tkey=\"val\\\nue\"", "foo", "value" }, + { FALSE, "conn foo\n\tkey=\"unterminated", "foo", NULL }, }; START_TEST(test_strings) |