Closed
Description
YAML has a bunch of special chars requiring to use quoted values instead of unquoted values when they appear in it.
However, the doc at http://symfony.com/doc/current/components/yaml/yaml_format.html does not describe them currently (and the YAML spec is rather complex to understand because of the way it is written)
the logic used by the dumper to know whether the escaping is necessary is available in the code:
- https://github.com/symfony/symfony/blob/f940d92a32e4d70cbe045ab8e1b3c70d3eb6061e/src/Symfony/Component/Yaml/Escaper.php#L42 for strings requiring a double quoted notation (this is any string containing control chars mostly). The common mistake in this case for people using a double quoted string is to forget to escape
\
chars in them, which causes issues when it is followed by one of the chars used in control chars representations. - https://github.com/symfony/symfony/blob/f940d92a32e4d70cbe045ab8e1b3c70d3eb6061e/src/Symfony/Component/Yaml/Escaper.php#L66 for strings requiring single quoted notation (without requiring the double quoted notation which is checked first). this is the regex where you will see the special chars causing issues when being used in unquoted values (there a a few cases where this regex will trigger the usage of quoted values in the dumping wile the unquoted values is fine, because spaces and quotes are an issues only at the beginning and the end for instance, but we choose the simpler implementation in the dumper)
The fact that people don't know about special chars is causing issues when one of them is parsed as a string value only because of a bug in the parser, as this breaks your file once the parser gets fixed (or when parsing it with a different parser than the Symfony one). See symfony/symfony#11835 for an example