From: Shannon C <reh...@gm...> - 2019-10-30 19:16:18
|
The `[+-]` of a float is optional in YAML 1.2's JSON schema tag resolution https://yaml.org/spec/1.2/spec.html#id2804356 and in YAML 1.2s core schema tag resolution https://yaml.org/spec/1.2/spec.html#id2805071. In YAML 1.1 it appeared to be required. This means that YAML 1.2 parses certain unquoted hex strings (git commits, hashes, etc.) as floats, for example: 504e199 would be parsed as a float instead of a string. This might be surprising if the YAML serialization library is not explicitly quoting strings or tagging them. I feel like this may be a weakness in the YAML 1.2 spec under 10.1.1.3 Generic String https://yaml.org/spec/1.2/spec.html#id2802842 where it describes the Canonical Form of strings glibly as "The obvious." I am not very familiar with how the spec works, but it seems to me that if there is no clearly described canonical form for strings, serialization tools are liable to produce output (like the example above) which does not produce accurate round-trip (reversible) serialization/deserialization. Is this an area which could be improved in the spec, so that YAML serializers are directed to serialize strings in a way which guarantees that it will deserialize back to the same thing? Barring that, is there any general advice for library authors or bug reporters about how serialization of such YAML strings should be performed, such as always quoting strings? Thanks! Shannon |