diff options
author | Joe Mooring <[email protected]> | 2024-01-13 10:28:39 -0800 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-01-16 09:26:44 +0100 |
commit | 912c6576bb47535bb29819c9855da90580e11906 (patch) | |
tree | 3dc341ceafb1ed274bf6be4da63650febf4a0bbf /tpl | |
parent | 911bc60a7ab739885908fdfe49d1578531940909 (diff) | |
download | hugo-912c6576bb47535bb29819c9855da90580e11906.tar.gz hugo-912c6576bb47535bb29819c9855da90580e11906.zip |
parser/metadecoders: Add CSV lazyQuotes option to transform.Unmarshal
If true, a quote may appear in an unquoted field and a non-doubled quote
may appear in a quoted field. It defaults to false.
Closes #11884
Diffstat (limited to 'tpl')
-rw-r--r-- | tpl/transform/integration_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tpl/transform/integration_test.go b/tpl/transform/integration_test.go index 3ba65c715..f035ec719 100644 --- a/tpl/transform/integration_test.go +++ b/tpl/transform/integration_test.go @@ -107,3 +107,29 @@ disableKinds = ['page','rss','section','sitemap','taxonomy','term'] _, err := b.BuildE() b.Assert(err.Error(), qt.Contains, "error calling highlight: invalid Highlight option: 0") } + +// Issue #11884 +func TestUnmarshalCSVLazyDecoding(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +disableKinds = ['page','rss','section','sitemap','taxonomy','term'] +-- assets/pets.csv -- +name,description,age +Spot,a nice dog,3 +Rover,"a big dog",5 +Felix,a "malicious" cat,7 +Bella,"an "evil" cat",9 +Scar,"a "dead cat",11 +-- layouts/index.html -- +{{ $opts := dict "lazyQuotes" true }} +{{ $data := resources.Get "pets.csv" | transform.Unmarshal $opts }} +{{ printf "%v" $data | safeHTML }} + ` + b := hugolib.Test(t, files) + + b.AssertFileContent("public/index.html", ` +[[name description age] [Spot a nice dog 3] [Rover a big dog 5] [Felix a "malicious" cat 7] [Bella an "evil" cat 9] [Scar a "dead cat 11]] + `) +} |