From 632265ec33f46ab4c777017fb45106defca4340e Mon Sep 17 00:00:00 2001 From: devangpratap <115096812+devangpratap@users.noreply.github.com> Date: Tue, 29 Sep 2026 12:27:24 -0400 Subject: [PATCH] Do not stay in the escape state after a backslash-newline in StringLiteral The empty case '\n' in the backslash state was meant to drop a backslash-newline pair like Python's python_string does, but it never reset the state, so the next character was parsed as an escape. --- tools/config/utils.go | 1 + tools/config/utils_test.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/tools/config/utils.go b/tools/config/utils.go index 4dcd2e479..ad35182b5 100644 --- a/tools/config/utils.go +++ b/tools/config/utils.go @@ -121,6 +121,7 @@ func StringLiteral(val string) (string, error) { case backslash: switch ch { case '\n': + state = normal case '\\': ans.WriteRune('\\') state = normal diff --git a/tools/config/utils_test.go b/tools/config/utils_test.go index 8e70dbfc3..4ce018f7c 100644 --- a/tools/config/utils_test.go +++ b/tools/config/utils_test.go @@ -18,6 +18,8 @@ func TestStringLiteralParsing(t *testing.T) { `abc`: `abc`, `a\nb\M`: "a\nb\\M", `a\x20\x1\u1234\123\12|`: "a \\x1\u1234\123\x0a|", + "a\\\nnb": "anb", + "a\\\n\\tb": "a\tb", } { actual, err := StringLiteral(q) if err != nil {