summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-08-21 10:48:28 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-08-21 10:48:28 +0200
commit8d7a77737c3fedc1b7e25cc5c15851bad4eaa63c (patch)
tree91d1aa6b7b216303594992ced9e71aeffd802a1e
parentb6538532f45bf833226da7277994c1a96d26a56c (diff)
Avoid escaping HTML chars inside hugo_stats.jsonfix/htmlcoll-enc-11371
Fixes #11371
-rw-r--r--hugolib/hugo_sites_build.go7
-rw-r--r--hugolib/site_test.go3
2 files changed, 8 insertions, 2 deletions
diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go
index 0c1ec050b..167d19eb5 100644
--- a/hugolib/hugo_sites_build.go
+++ b/hugolib/hugo_sites_build.go
@@ -492,10 +492,15 @@ func (h *HugoSites) writeBuildStats() error {
HTMLElements: *htmlElements,
}
- js, err := json.MarshalIndent(stats, "", " ")
+ var buf bytes.Buffer
+ enc := json.NewEncoder(&buf)
+ enc.SetEscapeHTML(false)
+ enc.SetIndent("", " ")
+ err := enc.Encode(stats)
if err != nil {
return err
}
+ js := buf.Bytes()
filename := filepath.Join(h.Configs.LoadingInfo.BaseConfig.WorkingDir, files.FilenameHugoStatsJSON)
diff --git a/hugolib/site_test.go b/hugolib/site_test.go
index f4d63943f..57c6bbabe 100644
--- a/hugolib/site_test.go
+++ b/hugolib/site_test.go
@@ -1116,7 +1116,7 @@ minify = %t
Some text.
-<div class="c d e" id="el2">Foo</div>
+<div class="c d e [&>p]:text-red-600" id="el2">Foo</div>
<span class=z>FOO</span>
@@ -1144,6 +1144,7 @@ Some text.
"d",
"e",
"hover:text-gradient",
+ "[&>p]:text-red-600",
"inline-block",
"lowercase",
"pb-1",