psych icon indicating copy to clipboard operation
psych copied to clipboard

dump is not escaping non-printable characters

Open Esaron opened this issue 2 years ago • 0 comments

I have some YAML with some values containing non-breaking spaces, correctly formatted according to the YAML spec's guidelines on escaped characters as "\_". Psych correctly loads these strings and converts them to non-breaking space characters (\u00A0). The issue is that when dumping back to YAML, Psych does not correctly escape these non-printable characters as specified by the spec.

Example

Expected

irb(main):002:0> Psych.dump(Psych.load('"\\_"'))
=> "--- \"\\_\"\n"

Actual

irb(main):002:0> Psych.dump(Psych.load('"\\_"'))
=> "--- \" \"\n"

Esaron avatar Feb 17 '23 02:02 Esaron