aboutsummaryrefslogtreecommitdiff
path: root/src/html
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2016-10-19 13:34:15 -0400
committerRuss Cox <rsc@golang.org>2016-10-24 15:44:30 +0000
commit2693fa15ee12acd67e45d8fa57626675903ab605 (patch)
treeb2d900963b67f73d0d227f9ddf0bc70f23a72b11 /src/html
parent604146ce8961d32f410949015fc8ee31f9052209 (diff)
downloadgo-2693fa15ee12acd67e45d8fa57626675903ab605.tar.xz
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: Quentin Smith <quentin@golang.org>
Diffstat (limited to 'src/html')
-rw-r--r--src/html/template/clone_test.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/html/template/clone_test.go b/src/html/template/clone_test.go
index 069064c98b..bbe44f98dd 100644
--- a/src/html/template/clone_test.go
+++ b/src/html/template/clone_test.go
@@ -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()))
+ }
+}