yaml / yaml-test-suite

Comprehensive, language independent Test Suite for YAML
MIT License
194 stars 64 forks source link

Colon in anchor is accepted #144

Open asomov opened 2 months ago

asomov commented 2 months ago

There is a clear restriction in the anchor names But the tests (Y2GN, 2SXE) still check that colon should be accepted as a valid character

perlpunk commented 2 months ago

There is a clear restriction in the anchor names

What do you mean by that? The 1.2 spec allows colons in anchor names: https://yaml.org/spec/1.2.2/#rule-ns-anchor-char

But the tests (Y2GN, 2SXE) still check that colon should be accepted as a valid character

The test suite is currently targeting YAML 1.2, so it's correct.

asomov commented 2 months ago

@perlpunk I mean that many parsers (including online checkers) do not allow colon in the anchor. It causes tons of misunderstanding SnakeYAML has to drop some test cases in the suite to stay sound.

perlpunk commented 1 month ago

I only saw the linked issue now: https://github.com/jruby/jruby/issues/8352 I answered there. The important point there is: an emitter must add a space after an alias, if it is used as a mapping key, otherwise the colon is parsed as part of the anchor.

*1 : true
# not:
# *1: true

We cannot fix this problem simply by removing those tests from the test suite. But you can fix Snake YAML to create valid YAML.