aboutsummaryrefslogtreecommitdiffhomepage
path: root/markup
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-04-22 18:12:49 +0200
committerBjørn Erik Pedersen <[email protected]>2024-04-22 19:10:15 +0200
commit509ab08c1b140de421c376235faa566f87ea666e (patch)
tree5e72a0d3b5c13adecced6e7471c50fe68f031537 /markup
parent2d75f539e14858a7b28484b2ad1f72db284892cb (diff)
downloadhugo-509ab08c1b140de421c376235faa566f87ea666e.tar.gz
hugo-509ab08c1b140de421c376235faa566f87ea666e.zip
markup/goldmark: Fix data race in the hugocontext wrapper
The window for this to happen is very small, but it has been reported by Go's race detector (-race flag) in a tests once.
Diffstat (limited to 'markup')
-rw-r--r--markup/goldmark/hugocontext/hugocontext.go4
-rw-r--r--markup/goldmark/hugocontext/hugocontext_test.go2
2 files changed, 3 insertions, 3 deletions
diff --git a/markup/goldmark/hugocontext/hugocontext.go b/markup/goldmark/hugocontext/hugocontext.go
index ed62bb8c6..b9c548dac 100644
--- a/markup/goldmark/hugocontext/hugocontext.go
+++ b/markup/goldmark/hugocontext/hugocontext.go
@@ -34,7 +34,7 @@ func New() goldmark.Extender {
// Wrap wraps the given byte slice in a Hugo context that used to determine the correct Page
// in .RenderShortcodes.
-func Wrap(b []byte, pid uint64) []byte {
+func Wrap(b []byte, pid uint64) string {
buf := bufferpool.GetBuffer()
defer bufferpool.PutBuffer(buf)
buf.Write(prefix)
@@ -45,7 +45,7 @@ func Wrap(b []byte, pid uint64) []byte {
buf.Write(b)
buf.Write(prefix)
buf.Write(closingDelimAndNewline)
- return buf.Bytes()
+ return buf.String()
}
var kindHugoContext = ast.NewNodeKind("HugoContext")
diff --git a/markup/goldmark/hugocontext/hugocontext_test.go b/markup/goldmark/hugocontext/hugocontext_test.go
index da96cc339..4a6eb80f5 100644
--- a/markup/goldmark/hugocontext/hugocontext_test.go
+++ b/markup/goldmark/hugocontext/hugocontext_test.go
@@ -24,7 +24,7 @@ func TestWrap(t *testing.T) {
b := []byte("test")
- c.Assert(string(Wrap(b, 42)), qt.Equals, "{{__hugo_ctx pid=42}}\ntest{{__hugo_ctx/}}\n")
+ c.Assert(Wrap(b, 42), qt.Equals, "{{__hugo_ctx pid=42}}\ntest{{__hugo_ctx/}}\n")
}
func BenchmarkWrap(b *testing.B) {