diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-05-26 08:13:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-26 08:13:39 +0200 |
commit | 762fa2b2ff61747aef5b3b58015fa3d7c4d9f383 (patch) | |
tree | 4d8b7640f5725880163523466a3f58f8eb8b94ef | |
parent | 5f097fbcef633a4f819bf31cfa43665ccfbc51b6 (diff) | |
parent | 27ebb97d0a51a3198f2c95cbdccd6f56274c19ee (diff) |
Merge pull request #6570 from edolstra/eof-in-string
Handle EOFs in string literals correctly
-rw-r--r-- | src/libexpr/lexer.l | 2 | ||||
-rw-r--r-- | tests/lang/parse-fail-eof-in-string.nix | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/libexpr/lexer.l b/src/libexpr/lexer.l index 4c28b976e..462b3b602 100644 --- a/src/libexpr/lexer.l +++ b/src/libexpr/lexer.l @@ -198,7 +198,7 @@ or { return OR_KW; } (...|\$[^\{\"\\]|\\.|\$\\.)+ would have triggered. This is technically invalid, but we leave the problem to the parser who fails with exact location. */ - return STR; + return EOF; } \'\'(\ *\n)? { PUSH_STATE(IND_STRING); return IND_STRING_OPEN; } diff --git a/tests/lang/parse-fail-eof-in-string.nix b/tests/lang/parse-fail-eof-in-string.nix new file mode 100644 index 000000000..19775d2ec --- /dev/null +++ b/tests/lang/parse-fail-eof-in-string.nix @@ -0,0 +1,3 @@ +# https://github.com/NixOS/nix/issues/6562 +# Note that this file must not end with a newline. +a 1"$
\ No newline at end of file |