From e8b0e1dd639ae297422c6efd920da84e2682e55c Mon Sep 17 00:00:00 2001 From: k1LoW Date: Thu, 28 Mar 2024 16:36:04 +0900 Subject: [PATCH] Quote is required even if it begins with backquote. --- encode_test.go | 5 +++++ token/token.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/encode_test.go b/encode_test.go index 3ff6f1c1..31bd6fec 100644 --- a/encode_test.go +++ b/encode_test.go @@ -318,6 +318,11 @@ func TestEncoder(t *testing.T) { map[string]string{"a": " b "}, nil, }, + { + "a: \"`b` c\"\n", + map[string]string{"a": "`b` c"}, + nil, + }, { "a: 100.5\n", map[string]interface{}{ diff --git a/token/token.go b/token/token.go index c86caab2..14d76220 100644 --- a/token/token.go +++ b/token/token.go @@ -623,7 +623,7 @@ func IsNeedQuoted(value string) bool { } first := value[0] switch first { - case '*', '&', '[', '{', '}', ']', ',', '!', '|', '>', '%', '\'', '"', '@', ' ': + case '*', '&', '[', '{', '}', ']', ',', '!', '|', '>', '%', '\'', '"', '@', ' ', '`': return true } last := value[len(value)-1]