Anchor should allow non ascii charactors

Issue #468 resolved
Takafumi Ohtake created an issue

Summary

When snakeyaml loads a yaml that has an anchor contains non ascii charactors like Japanese, Chinese or Germany, An following error is produced.

while scanning an anchor
in 'string', line 23, column 11:
- name: &something_タスク タスク
^
expected alphabetic or numeric character, but found タ(12479)
in 'string', line 23, column 22:
- name: &something_タスク タスク

Environment

  • java

    • 1.8
  • snakeyaml

    • 1.24

Expected

  • Yaml specification allows non ascii characters. Snakeyaml should do so.

Detail

The javadoc of the method produces the error says following.

The specification does not restrict characters for anchors and
aliases. This may lead to problems, for instance, the document:
  [ *alias, value ]
can be interpreted in two ways, as
  [ "value" ]
and
  [ *alias , "value" ]
Therefore we restrict aliases to numbers and ASCII letters.

But yaml 1.2 defines exclude characters “,“ , ”[” , “]“ , “{“ , “}“ for anchors to avoid the problem.
https://yaml.org/spec/1.2/spec.html#id2785586

Snakeyaml may follow yaml 1.1. But current implementation is neither following yaml 1.1 nor 1.2.
The best way to avoid problems caused from flow characters should follow yaml 1.2 specification.

Comments (5)

  1. Log in to comment