From 7dc5550057dd9971f02a5689c16f5660ad32565a Mon Sep 17 00:00:00 2001 From: Thomas Pelletier Date: Sun, 28 Mar 2021 00:17:58 -0400 Subject: [PATCH] Fix multiline basic string parsing --- parser.go | 1 + unmarshaler_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/parser.go b/parser.go index 6e5b36c..867ef0f 100644 --- a/parser.go +++ b/parser.go @@ -493,6 +493,7 @@ func (p *parser) parseMultilineBasicString(b []byte) ([]byte, []byte, error) { for ; i < len(token)-3; i++ { c := token[i] if !(c == '\n' || c == '\r' || c == ' ' || c == '\t') { + i-- break } } diff --git a/unmarshaler_test.go b/unmarshaler_test.go index 9acb3be..c84e866 100644 --- a/unmarshaler_test.go +++ b/unmarshaler_test.go @@ -192,6 +192,20 @@ func TestUnmarshal(t *testing.T) { } }, }, + { + desc: "multiline basic string", + input: `A = """\ + Test"""`, + gen: func() test { + type doc struct { + A string + } + return test{ + target: &doc{}, + expected: &doc{A: "Test"}, + } + }, + }, { desc: "kv bool true", input: `A = true`,