dtolnay / serde-yaml

Strongly typed YAML library for Rust
Apache License 2.0
960 stars 157 forks source link

Strings that are commonly interpreted as booleans by other YAML parsers are not escaped #380

Open Whodiduexpect opened 1 year ago

Whodiduexpect commented 1 year ago

Serde-yaml creates ambiguous YAML during the serialization of keys with string values that could be considered boolean in YAML 1.1. For instance, serializing foo with the string value no results in foo: no. Many YAML 1.2 parsers would still interpret no as boolean due to continued support for 1.1 booleans. I ran into this issue using Python's yaml module:

>>> import yaml
>>> data = yaml.safe_load("foo: no")
>>> print(data)
{'foo': False}

To avoid YAML created from serde-yaml being misinterpreted by many YAML parsers, string values that may be seen as booleans should be quoted or otherwise disambiguated from YAML 1.1 boolean values.