clovyr / aeson-yaml

Encode any Aeson (JSON) value as YAML (in pure Haskell)
https://hackage.haskell.org/package/aeson-yaml
BSD 3-Clause "New" or "Revised" License
12 stars 7 forks source link

Single-quote more pathological strings #9

Closed Gabriella439 closed 4 years ago

Gabriella439 commented 4 years ago

See: https://github.com/dhall-lang/dhall-haskell/issues/1939

patrickmn commented 4 years ago

Hi Gabriel,

Unfortunately I merged this too quickly. Reverted it in https://github.com/clovyr/aeson-yaml/pull/10 for now.

The behavior of shouldSingleQuote is off given this change -- for example, a line containing \n (or other arbitrary symbols) but ALSO a trailing space is now single-quoted because any one of the conditions are sufficient to single-quote any string, including ones that may not be safe to single-quote.

The test cases didn't catch this because none of the double-quoted test cases meet any of the shouldSingleQuote ORs.

If you'd like, I can try to patch, but it may not be until later in the week.