Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colon in anchor is accepted #144

Open
asomov opened this issue Sep 25, 2024 · 3 comments
Open

Colon in anchor is accepted #144

asomov opened this issue Sep 25, 2024 · 3 comments

Comments

@asomov
Copy link
Contributor

asomov commented Sep 25, 2024

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
Copy link
Member

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
Copy link
Contributor Author

asomov commented Sep 25, 2024

@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
Copy link
Member

perlpunk commented Oct 6, 2024

I only saw the linked issue now: jruby/jruby#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants