4 ms·
Preface: this is why people like to complain about YAML, but really I think it's a feature and not a bug that you can write strings in so many different ways, t
by nerdponx 6y ago
Preface: this is why people like to complain about YAML, but really I think it's a feature and not a bug that you can write strings in so many different ways, to serve the many different needs for entering text into config files.
This is probably not a common piece of YAML knowledge, but it's arguably better to use "folded" style for a password:
password: >-2\n
asdjoi'";j;oj;90\[2301@
Or use single quotes, which signals to the YAML parser not to treat any characters as special, but then you need to escape the literal SINGLE QUOTE character (') by doubling it:
password: 'asdjoi''";j;oj;90\[2301@'
This is completely valid yaml that reduces to the JSON equivalent:
{"password": "asdjoi'\";j;oj;90\\[2301@"}
And of course you can always write JSON syntax for when the text escaping gets hairy, because YAML is a superset of JSON.
Here they are together:
password1: >-2
asdjoi'";j;oj;90\[2301@
password2: 'asdjoi''";j;oj;90\[2301@'
password3: "asdjoi'\";j;oj;90\\[2301@"
See here (https://yaml-multiline.info/ https://yaml-multiline.info/) for a summary of the various multi-line text styles.