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

Syntax error on valid characters in anchor names #686

Open
Freso opened this issue Aug 25, 2024 · 1 comment
Open

Syntax error on valid characters in anchor names #686

Freso opened this issue Aug 25, 2024 · 1 comment

Comments

@Freso
Copy link

Freso commented Aug 25, 2024

yamllint complains about the use of periods (.) in anchor names. As far as I can discern, ns-anchor-char allows all ns-chars except for c-flow-indicators (,[]{}).

Periods (.) are x2E which is well within the range of [x20-x7E] given in c-printable and is not one of the chars excluded from ns-char via b-char, c-byte-order-mark, or s-white.

I don’t see any way to configure yamllint to not balk on this, or at least reduce this to a warning (other than comment-disabling). I can definitely see limiting anchor names to alphanumeric characters to be desired for many use cases (for compatibility/interoperability), but the spec allows for a wider range of characters used here, so this should probably reasonably be a configuration toggle.

%YAML 1.2
---
test:
  - &test-with-.period "This is a test of an anchor with a period (`.`)."
test2:
  - *test-with-.period
...
> yamllint --version
yamllint 1.35.1
> yamllint test.yaml
test.yaml
  4:16      error    syntax error: expected alphabetic or numeric character, but found '.' (syntax)
@perlpunk
Copy link

I just want to comment that the underlying issue is in pyyaml.
It is more restrictive than the YAML spec regarding what is allowed in anchor names.
yaml/pyyaml#373
yaml/pyyaml#389
The current pyyaml maintainer wants to keep it that way. The same is true for libyaml, btw.

Not sure if yamllint can work around that syntax error from pyyaml.

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