Skip to content

Commit

Permalink
fix parsing of tab character in double-quote
Browse files Browse the repository at this point in the history
  • Loading branch information
goccy committed Nov 15, 2024
1 parent 8b2110b commit af083b8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lexer/lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 4 additions & 0 deletions scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit af083b8

Please sign in to comment.