From 237df0ef1c53d7c1732e6afb1fcfd85dd1745637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ken=E2=80=99ichiro=20Oyama?= Date: Tue, 16 Jul 2024 19:39:25 +0900 Subject: [PATCH] Quote is required even if it begins with backquote. (#440) --- 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 9ca44040..74388b98 100644 --- a/encode_test.go +++ b/encode_test.go @@ -338,6 +338,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]