From f6e5925f30222534497bd250b77da20253fe0acf Mon Sep 17 00:00:00 2001 From: electricface Date: Tue, 10 Oct 2023 13:50:55 +0800 Subject: [PATCH] Fix '\t' (byte(9)) in multiline string is invalid Signed-off-by: electricface --- decode.go | 2 +- scanner.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/decode.go b/decode.go index 005431f..e322d42 100644 --- a/decode.go +++ b/decode.go @@ -1291,7 +1291,7 @@ func unquoteBytes(s []byte) (t []byte, ok bool) { } // Quote, control characters are invalid. - case orig[0] == '"' && c == '"', orig[0] == '\'' && c == '\'', c < ' ': + case orig[0] == '"' && c == '"', orig[0] == '\'' && c == '\'', c < ' ' && c != '\t': return // ASCII diff --git a/scanner.go b/scanner.go index 283459a..78d3c43 100644 --- a/scanner.go +++ b/scanner.go @@ -457,6 +457,9 @@ func stateInStringDouble(s *scanner, c byte) int { s.step = stateInStringEsc(stateInStringDouble) return scanContinue } + if c == '\t' { + return scanContinue + } if c < 0x20 { return s.error(c, "in string literal") }