Commit 2693fa15 authored by Russ Cox's avatar Russ Cox

html/template: add test case for unbounded template expansion

Fixed by CL 31092 already, but that change is a few steps away
from the problem observed here, so add an explicit test.

Fixes #17019.

Change-Id: If4ece1418e6596b1976961347889ce12c5969637
Reviewed-on: https://go-review.googlesource.com/31466
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarQuentin Smith <quentin@golang.org>
parent 604146ce
......@@ -229,3 +229,15 @@ func TestTemplateCloneLookup(t *testing.T) {
t.Error("after Clone, tmpl.Lookup(tmpl.Name()) != tmpl")
}
}
func TestCloneGrowth(t *testing.T) {
tmpl := Must(New("root").Parse(`<title>{{block "B". }}Arg{{end}}</title>`))
tmpl = Must(tmpl.Clone())
Must(tmpl.Parse(`{{define "B"}}Text{{end}}`))
for i := 0; i < 10; i++ {
tmpl.Execute(ioutil.Discard, nil)
}
if len(tmpl.DefinedTemplates()) > 200 {
t.Fatalf("too many templates: %v", len(tmpl.DefinedTemplates()))
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment