summaryrefslogtreecommitdiffstats
path: root/src/config.l
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-03-28 21:51:07 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-03-28 21:51:07 +0200
commitae9df63aa9cb400e7c169b654f23a5b9e368aa7e (patch)
tree3a672194c41f3c409c75c94840352c72976ab91a /src/config.l
parent14a44b4016d3350c85c419e1e1b683c1574cd86e (diff)
downloadfastd-ae9df63aa9cb400e7c169b654f23a5b9e368aa7e.tar
fastd-ae9df63aa9cb400e7c169b654f23a5b9e368aa7e.zip
Config: allow escaping quotes in strings
Diffstat (limited to 'src/config.l')
-rw-r--r--src/config.l27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/config.l b/src/config.l
index 8a96b40..b1e61e6 100644
--- a/src/config.l
+++ b/src/config.l
@@ -26,6 +26,9 @@ secret { return TOK_SECRET; }
key { return TOK_KEY; }
include { return TOK_INCLUDE; }
as { return TOK_AS; }
+any { return TOK_ANY; }
+tap { return TOK_TAP; }
+tun { return TOK_TUN; }
[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} {
if (!inet_pton(AF_INET, yytext, &yylval->addr)) {
@@ -36,19 +39,29 @@ as { return TOK_AS; }
return TOK_ADDR;
}
-any { yylval->str = yytext; return TOK_ANY; }
-tap { yylval->str = yytext; return TOK_TAP; }
-tun { yylval->str = yytext; return TOK_TUN; }
-
[;:\{\}] { return yytext[0]; }
[ \t\n] ;
}
-<INITIAL>\"\" { yylval->str = strdup(""); return TOK_STRING; }
<INITIAL>\" BEGIN(STRING);
-<STRING>[^"]+ { yylval->str = strdup(yytext); return TOK_STRING; }
-<STRING>\" BEGIN(INITIAL);
+<STRING>[^"\\]* yymore();
+<STRING>\\(.|\n) yymore();
+<STRING>\" {
+ int i, esc = 0;
+
+ for (i = 0; i < yyleng; i++) {
+ if (yytext[i] == '\\')
+ esc++;
+ else if(esc)
+ yytext[i-esc] = yytext[i];
+ }
+ yytext[yyleng-esc-1] = 0;
+ yylval->str = strdup(yytext);
+ BEGIN(INITIAL);
+ return TOK_STRING;
+
+ }
<INITIAL>\[ BEGIN(ADDR6);
<ADDR6>[^\]]+ {