]> Cypherpunks repositories - gostls13.git/commit
html/template: use the same escaper across multiple template executions
authorSamuel Tan <samueltan@google.com>
Wed, 5 Jul 2017 23:28:41 +0000 (16:28 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 14 Jul 2017 18:19:04 +0000 (18:19 +0000)
commita005a8d1b4ab37c1f5fd200fc57d2a67ce87c8ac
treead9ea47f38a359bcbf35831cdb8d5ac8e0232950
parent9664bc1d1ff8ee2ddcea37d335ca4510a57a1e0c
html/template: use the same escaper across multiple template executions

The escaper contains information about which templates have already been
visited and escaped. This information is necessary to prevent templates
that have already been escaped from being over-escaped. However, since we
currently create a new escaper each time we execute a template, this
information does not persist across multiple template executions.

Fix this by saving an escaper in each template name space which is shared by
all templates in that name space.

While there, fix error message formatting for an escaping unit test.

Fixes #20842

Change-Id: Ie392c3e7ce0e0a9947bdf56c99e926e7c7db76e4
Reviewed-on: https://go-review.googlesource.com/47256
Reviewed-by: Mike Samuel <mikesamuel@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/html/template/escape.go
src/html/template/escape_test.go
src/html/template/template.go