Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure mapping values are quoted when they contain a : separtor #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Data/Aeson/Yaml.hs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ encodeText canMultiline alwaysQuote level s
s /= "" && -- s is not empty
Text.all isAllowed s && -- s consists of acceptable chars
(Data.Char.isAlpha headS || -- head of s is a char in A-Z or a-z or indicates a filepath
headS == '/')
headS == '/') &&
not (Text.isInfixOf ": " s) -- s contains a mapping separator
isBoolString
| Text.length s > 5 = False
| otherwise =
Expand Down
4 changes: 2 additions & 2 deletions test/Test/Data/Aeson/Yaml.hs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ tcHelloWorld =
{ tcName = "Hello World"
, tcInput =
[s|
{ "image": "node 10.15.3"
{ "image": "node: 10.15.3"
, "pipelines":
{ "default":
[ { "step":
Expand All @@ -230,7 +230,7 @@ tcHelloWorld =
}
|]
, tcOutput =
[s|image: node 10.15.3
[s|image: "node: 10.15.3"
pipelines:
default:
- step:
Expand Down