diff options
author | Guillaume Maudoux <layus.on@gmail.com> | 2015-07-02T21·53+0200 |
---|---|---|
committer | Guillaume Maudoux <layus.on@gmail.com> | 2015-07-03T12·09+0200 |
commit | 467977f20326f704b259157652ee9b7ba2efaa78 (patch) | |
tree | 2aef3ca8cad3613e09a71cd3811164ffcab46ecf /src/libexpr/lexer.l | |
parent | 65e4dcd69bb618ef2bf07ec128b207df3d9e868a (diff) |
Fix the parsing of "$"'s in strings.
Diffstat (limited to 'src/libexpr/lexer.l')
-rw-r--r-- | src/libexpr/lexer.l | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/libexpr/lexer.l b/src/libexpr/lexer.l index 7483e5cc4acb..1f2957ec71ad 100644 --- a/src/libexpr/lexer.l +++ b/src/libexpr/lexer.l @@ -129,12 +129,11 @@ or { return OR_KW; } \} { POP_STATE(); return '}'; } \" { PUSH_STATE(STRING); return '"'; } -<STRING>([^\$\"\\]|\$[^\{\"]|\\.)+ { - /* !!! Not quite right: we want a follow restriction on - "$", it shouldn't be followed by a "{". Right now - "$\"" will be consumed as part of a string, rather - than a "$" followed by the string terminator. - Disallow "$\"" for now. */ +<STRING>([^\$\"\\]|\$[^\{\"\\]|\\.|\$\\.)*\$/\" | +<STRING>([^\$\"\\]|\$[^\{\"\\]|\\.|\$\\.)+ { + /* It is impossible to match strings ending with '$' with one + regex because trailing contexts are only valid at the end + of a rule. (A sane but undocumented limitation.) */ yylval->e = unescapeStr(data->symbols, yytext); return STR; } |