diff --git a/src/libexpr/lexer.l b/src/libexpr/lexer.l index 892543ec2e..fb19e16b45 100644 --- a/src/libexpr/lexer.l +++ b/src/libexpr/lexer.l @@ -77,7 +77,11 @@ inherit { return INHERIT; } } \" { BEGIN(STRING); return '"'; } -([^\$\"\\]|\\.)+ { +([^\$\"\\]|\$[^\{\"]|\\.)+ { +/* !!! 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. */ yylval->t = unescapeStr(yytext); /* !!! alloc */ return STR; } diff --git a/tests/lang/eval-okay-string.exp b/tests/lang/eval-okay-string.exp index dd0e5e248d..335e3281e3 100644 --- a/tests/lang/eval-okay-string.exp +++ b/tests/lang/eval-okay-string.exp @@ -1 +1 @@ -Str("foobar/a/b/c/d/foo/xyzzy/foo.txt/../foo/x/yescape: \"quote\" \n \\end\nof\nlinefoobarblaat") +Str("foobar/a/b/c/d/foo/xyzzy/foo.txt/../foo/x/yescape: \"quote\" \n \\end\nof\nlinefoobarblaatfoo$bar") diff --git a/tests/lang/eval-okay-string.nix b/tests/lang/eval-okay-string.nix index f2452e8574..086ba4bf92 100644 --- a/tests/lang/eval-okay-string.nix +++ b/tests/lang/eval-okay-string.nix @@ -7,3 +7,4 @@ of line" + "foo${if true then "b${"a" + "r"}" else "xyzzy"}blaat" + + "foo$bar"