From d7847dbcfd7df97a7b74c90b3eff88b278cf178c Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Fri, 15 Nov 2024 09:29:57 +0900 Subject: [PATCH] fix parsing of tab character in double-quote (#538) --- lexer/lexer_test.go | 12 ++++++++++++ scanner/scanner.go | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/lexer/lexer_test.go b/lexer/lexer_test.go index 7b678c4b..b7950415 100644 --- a/lexer/lexer_test.go +++ b/lexer/lexer_test.go @@ -38,6 +38,18 @@ func TestTokenize(t *testing.T) { }, }, }, + { + YAML: `"hello\tworld"`, + Tokens: token.Tokens{ + { + Type: token.DoubleQuoteType, + CharacterType: token.CharacterTypeIndicator, + Indicator: token.QuotedScalarIndicator, + Value: "hello\tworld", + Origin: `"hello\tworld"`, + }, + }, + }, { YAML: `0x_1A_2B_3C`, Tokens: token.Tokens{ diff --git a/scanner/scanner.go b/scanner/scanner.go index fbddf7d2..366d18e1 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -345,6 +345,10 @@ func (s *Scanner) scanDoubleQuote(ctx *Context) (*token.Token, error) { progress = 1 ctx.addOriginBuf(nextChar) value = append(value, '\r') + case 't': + progress = 1 + ctx.addOriginBuf(nextChar) + value = append(value, '\t') case 'v': progress = 1 ctx.addOriginBuf(nextChar)