Skip to content

Commit

Permalink
Fix unknown secondary tag behavior (#572)
Browse files Browse the repository at this point in the history
* fix unknown secondary tag behavior

* fix test case
  • Loading branch information
goccy authored Dec 5, 2024
1 parent a91fb5b commit 783b85c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
3 changes: 0 additions & 3 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -880,9 +880,6 @@ func (p *parser) parseTagValue(ctx *context, tagRawTk *token.Token, tk *Token) (
}
return p.parseSequence(ctx)
}
if strings.HasPrefix(tagRawTk.Value, "!!") {
return nil, errors.ErrSyntax(fmt.Sprintf("unknown secondary tag name %q specified", tagRawTk.Value), tagRawTk)
}
return p.parseToken(ctx, tk)
}

Expand Down
9 changes: 1 addition & 8 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func TestParser(t *testing.T) {
"%YAML 1.2\n---\n",
"a: !!binary gIGC\n",
"a: !!binary |\n " + strings.Repeat("kJCQ", 17) + "kJ\n CQ\n",
"v: !!foo 1",
"v:\n- A\n- |-\n B\n C\n",
"v:\n- A\n- >-\n B\n C\n",
"v: |-\n 0\n",
Expand Down Expand Up @@ -1029,14 +1030,6 @@ func TestSyntaxError(t *testing.T) {
source string
expect string
}{
{
`v: !!int64 2`,
`
[1:4] unknown secondary tag name "!!int64" specified
> 1 | v: !!int64 2
^
`,
},
{
`
a:
Expand Down
1 change: 1 addition & 0 deletions yaml_test_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var failureTestNames = []string{
"implicit-flow-mapping-key-on-one-line", // no json.
"invalid-comment-after-comma",
"invalid-comment-after-end-of-flow-sequence",
"invalid-comma-in-tag",
"invalid-tag",
"leading-tabs-in-double-quoted/02",
"leading-tabs-in-double-quoted/05",
Expand Down

0 comments on commit 783b85c

Please sign in to comment.