ruby / psych

A libyaml wrapper for Ruby
MIT License
564 stars 203 forks source link

Alias names are too permissive in SnakeYAML-Engine #689

Open headius opened 1 week ago

headius commented 1 week ago

See original issue at jruby/jruby#8352.

The following YAML fails to parse in SnakeYAML-Engine, used by the JRuby Psych extension:

--- &1 !ruby/object:Set
hash:
  :one: true
  :two: true
  *1: true

This is due to a bug in SnakeYAML-Engine reported here: https://bitbucket.org/snakeyaml/snakeyaml-engine/issues/54/do-not-allow-colon-to-be-a-part-of-an

This will be fixed shortly in an upcoming release of SnakeYAML-Engine. Psych will need to be updated to the new version and released.

perlpunk commented 1 week ago

The proper fix is to add a space after the alias:

  *1 : true

It's valid to have a colon in anchor names (and yes, I agree that it should have been forbidden, but it isn't).