diff --git a/decode_test.go b/decode_test.go index 9be730e..85b7712 100644 --- a/decode_test.go +++ b/decode_test.go @@ -810,7 +810,7 @@ func TestDecoder(t *testing.T) { }, { "a: \"\\0\"\n", - map[string]string{"a": "\\0"}, + map[string]string{"a": "\x00"}, }, { "b: 2\na: 1\nd: 4\nc: 3\nsub:\n e: 5\n", diff --git a/lexer/lexer_test.go b/lexer/lexer_test.go index 7179517..052c00a 100644 --- a/lexer/lexer_test.go +++ b/lexer/lexer_test.go @@ -1347,7 +1347,7 @@ t4: 2098-01-09T10:40:47Z Type: token.DoubleQuoteType, CharacterType: token.CharacterTypeIndicator, Indicator: token.QuotedScalarIndicator, - Value: "\\0", + Value: "\x00", Origin: " \"\\0\"", }, }, diff --git a/scanner/scanner.go b/scanner/scanner.go index bc8701f..897610b 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -454,10 +454,20 @@ func (s *Scanner) scanDoubleQuote(ctx *Context) (*token.Token, error) { progress = 1 ctx.addOriginBuf(nextChar) value = append(value, nextChar) + case '0': + progress = 1 + ctx.addOriginBuf(nextChar) + value = append(value, '\x00') case ' ': // skip escape character. default: - value = append(value, c) + s.progressColumn(ctx, 1) + return nil, ErrInvalidToken( + token.Invalid( + fmt.Sprintf("found unknown escape character %q", nextChar), + string(ctx.obuf), s.pos(), + ), + ) } idx += progress s.progressColumn(ctx, progress) diff --git a/yaml_test_suite_test.go b/yaml_test_suite_test.go index 8be712e..b76420f 100644 --- a/yaml_test_suite_test.go +++ b/yaml_test_suite_test.go @@ -50,7 +50,6 @@ var failureTestNames = []string{ "implicit-flow-mapping-key-on-one-line", // no json. "invalid-comment-after-comma", "invalid-comment-after-end-of-flow-sequence", - "invalid-escape-in-double-quoted-string", "invalid-tag", "key-with-anchor-after-missing-explicit-mapping-value", "leading-tabs-in-double-quoted/02",