2 ms·
Purely my problem for not knowing but I ran into an issue of where I needed to escape characters in a password in a yaml file. Having said that I really like ya
by ketamine__ 6y ago
Purely my problem for not knowing but I ran into an issue of where I needed to escape characters in a password in a yaml file. Having said that I really like yaml as a Ruby dev.
- eurasiantiger 6y agoWhat is a non-trivial password doing in a YAML file?
- ketamine__ 6y agoIt's an encrypted yaml file.
- nerdponx 6y agoPreface: 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.