tpl: Detect and fail on infinite template recursion

Fixes #13627
This commit is contained in:
Bjørn Erik Pedersen
2025-04-20 18:20:17 +02:00
parent be3b147860
commit 1408c156d8
7 changed files with 68 additions and 38 deletions

View File

@@ -1229,3 +1229,19 @@ layouts/list.html
b.AssertFileContent("public/p1/index.html", "layouts/single.html")
}
}
func TestTemplateLoop(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
-- layouts/_partials/p.html --
p: {{ partial "p.html" . }}
-- layouts/all.html --
{{ partial "p.html" . }}
`
b, err := hugolib.TestE(t, files)
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, "error calling partial: maximum template call stack size exceeded")
}