mk-fg / pretty-yaml

PyYAML-based module to produce a bit more pretty and readable YAML-serialized data
Do What The F*ck You Want To Public License
135 stars 29 forks source link

pretty-yaml creates output not readable by itself for escaped strings #40

Closed EJahren closed 2 years ago

EJahren commented 2 years ago

For escaped input such as

"|\U000F1988\U0002CB8D\U0003176D\xA2\U000E5BCA\xEC\xCB": "\U0001C716\U000E5AE3\x92\
  d\x8C\xD9"

which PYYaml does parse.

pretty-yaml produces unescaped output, ie.:

T2Ÿx𳑡򶺳򗄌x.?¯𜿨¬: y񒟴񉲺񢤮𭀟𺭽Ê𞛎

which PYYaml does not parse.

EJahren commented 2 years ago

Closing this as I just realized this probably goes under the general warning stated in the README.

mk-fg commented 2 years ago

Yeah, this module is indeed an old bag of hacks to optimistically avoid escaping and dump things more plainly, which has a lot of cases like this for complicated inputs. Some of these issues might be easy to avoid and add a special-case for, but here I think it's relatively rare and complicated special-case, with fix being to check string via unicodedata to pick quoting style - probably not worth bothering with. Definitely don't use this module for serializing that kind of unreadable stuff.