]> Cypherpunks repositories - gostls13.git/commit
html/template: prevent panic when escaping actions involving chain nodes
authorDidier Spezia <didier.06@gmail.com>
Thu, 21 May 2015 21:35:49 +0000 (21:35 +0000)
committerRob Pike <r@golang.org>
Mon, 1 Jun 2015 20:52:04 +0000 (20:52 +0000)
commitf6853369c315d69a77163756e916e784bfe2e281
tree456a1c8715c3722040b3930b20bd2f68093b9153
parentae38ef4cdf2e8cf843b9d3872e66586327d744ae
html/template: prevent panic when escaping actions involving chain nodes

The current escape code panics when an action involves chain nodes.
Such nodes can be seen in the following situation:

{{ . | AAA.B }} - AAA being a registered function

The above expression is actually valid, because AAA could return a
map containing a B key. The tests in text/template explicitly
demonstrate this case.

Fix allIdents to cover also chain nodes.

While I was investigating this issue, I realized that the tests
introduced in similar CL 9621 were incorrect. Parse errors were
caught as expected, but for the wrong reason. Fixed them as well.
No changes in text/template code itself.

Fixes #10801

Change-Id: Ic9fe43b63669298ca52c3f499e2725dd2bb818a8
Reviewed-on: https://go-review.googlesource.com/10340
Reviewed-by: Rob Pike <r@golang.org>
src/html/template/escape.go
src/html/template/escape_test.go
src/text/template/parse/parse_test.go