marshal: don't escape quotes unnecessarily (#991)

Only 3 consecutive quotation marks need to be quoted. We choose to quote
all quotation marks in a sequence if there are 3 or more consecutive
present.

Fixes #990

---------

Co-authored-by: Thomas Pelletier <thomas@pelletier.dev>
This commit is contained in:
Dustin Spicuzza
2025-08-21 02:19:16 -04:00
committed by GitHub
parent 098464b61b
commit 6d56ac8027
2 changed files with 64 additions and 2 deletions
+48
View File
@@ -387,6 +387,54 @@ name = 'Alice'
expected: `A = """
hello
world"""
`,
},
{
desc: "multi-line quotation",
v: struct {
A string `toml:",multiline"`
}{
A: "hello\n\"world\"",
},
expected: `A = """
hello
"world""""
`,
},
{
desc: "multi-line triple quotation",
v: struct {
A string `toml:",multiline"`
}{
A: "hello\n\"\"\"world\"",
},
expected: `A = """
hello
\"\"\"world""""
`,
},
{
desc: "multi-line triple quotation",
v: struct {
A string `toml:",multiline"`
}{
A: "hello\n\"world\"\"\"",
},
expected: `A = """
hello
"world\"\"\""""
`,
},
{
desc: "multi-line sextuple quotation",
v: struct {
A string `toml:",multiline"`
}{
A: "hello\n\"\"\"\"\"\"world\"",
},
expected: `A = """
hello
\"\"\"\"\"\"world""""
`,
},
{