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

:@ reported as an invalid plain value in some flow contexts #316

Closed
cemerick opened this issue Sep 28, 2021 · 5 comments
Closed

:@ reported as an invalid plain value in some flow contexts #316

cemerick opened this issue Sep 28, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@cemerick
Copy link
Contributor

Describe the bug
The character sequence :@ is a valid flow plain value, but is reported as invalid in some contexts.

Other sequences involving characters that are barred from starting a plain scalar are also reported as invalid, including `, %, and probably others.

To Reproduce

yaml.parseDocument("[[], :@]")

The reported error is Plain value cannot start with reserved character @ at line 1, column 7:\n\n[[], :@]\n ^\n

Expected behaviour

A successful parse, with document contents of a sequence with two members (one empty sequence, and the string scalar ":@").

Versions (please complete the following information):

  • Environment: node v10.20.1
  • yaml: yaml@2.0.0-8

Additional context
I found mixed performance on this example (libfyaml and libyaml both parse successfully, but pyyaml and others do not), so I asked in the main YAML matrix chat. ingy confirmed that the input text is valid yaml, and suggested filing an issue on the yaml test suite, which I will be doing shortly.

@cemerick cemerick added the bug Something isn't working label Sep 28, 2021
@cemerick
Copy link
Contributor Author

ingy further suggested that this might be a regression, and so it is: with yaml@1.10.2, the repro in the report here works as expected.

@ingydotnet
Copy link

@ingydotnet
Copy link

Discussion happened in https://matrix.to/#/#chat:yaml.io so read that too...

@eemeli eemeli closed this as completed in 0e0d725 Sep 28, 2021
@eemeli
Copy link
Owner

eemeli commented Sep 28, 2021

Thank you for spotting this! This was a lexer bug: a flag for tracking if a flow-collection key is a json-node was not being reset after the , character. The first [] set this flag, and then when parsing :@ it was still mistakenly on, leading to the : to be considered as a separator that does not need a subsequent space, and hence ending up with a mis-parsed value of @, i.e. a reserved character. And that's then the error that you actually saw.

@cemerick
Copy link
Contributor Author

cemerick commented Sep 28, 2021

I'm glad the report was helpful.

FYI, I've upgraded my installation to master, and I can confirm the fix is effective. I really appreciate the super-fast turnaround, thank you for the great library. 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants