From f6853369c315d69a77163756e916e784bfe2e281 Mon Sep 17 00:00:00 2001 From: Didier Spezia Date: Thu, 21 May 2015 21:35:49 +0000 Subject: 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 --- src/text/template/parse/parse_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/text/template/parse/parse_test.go') diff --git a/src/text/template/parse/parse_test.go b/src/text/template/parse/parse_test.go index 9e62bd2df6..200d50c194 100644 --- a/src/text/template/parse/parse_test.go +++ b/src/text/template/parse/parse_test.go @@ -272,8 +272,8 @@ var parseTests = []parseTest{ // Wrong pipeline {"wrong pipeline dot", "{{12|.}}", hasError, ""}, {"wrong pipeline number", "{{.|12|printf}}", hasError, ""}, - {"wrong pipeline string", "{{.|print|\"error\"}}", hasError, ""}, - {"wrong pipeline char", "{{12|print|html|'e'}}", hasError, ""}, + {"wrong pipeline string", "{{.|printf|\"error\"}}", hasError, ""}, + {"wrong pipeline char", "{{12|printf|'e'}}", hasError, ""}, {"wrong pipeline boolean", "{{.|true}}", hasError, ""}, {"wrong pipeline nil", "{{'c'|nil}}", hasError, ""}, {"empty pipeline", `{{printf "%d" ( ) }}`, hasError, ""}, -- cgit v1.3-6-g1900