From 00a1ab9104d7b556623339f37ecc8852bc58ff70 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Thu, 7 Nov 2019 18:08:12 +0900 Subject: [PATCH] Fix handling of quotation character --- decode_test.go | 4 ++++ scanner/scanner.go | 12 +++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/decode_test.go b/decode_test.go index d41ed480..0319398b 100644 --- a/decode_test.go +++ b/decode_test.go @@ -804,6 +804,10 @@ func TestDecoder(t *testing.T) { "v: 1[]{},!%?&*", map[string]string{"v": "1[]{},!%?&*"}, }, + { + "v: user's item", + map[string]string{"v": "user's item"}, + }, { "v: [1,[2,[3,[4,5],6],7],8]", map[string]interface{}{ diff --git a/scanner/scanner.go b/scanner/scanner.go index 5b3957a3..531bfa60 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -452,11 +452,13 @@ func (s *Scanner) scan(ctx *Context) (pos int) { pos += progress return case '\'', '"': - token, progress := s.scanQuote(ctx, c) - ctx.addToken(token) - s.progressColumn(ctx, progress) - pos += progress - return + if ctx.bufferedSrc() == "" { + token, progress := s.scanQuote(ctx, c) + ctx.addToken(token) + s.progressColumn(ctx, progress) + pos += progress + return + } case '\n': s.scanNewLine(ctx, c) continue