]> Cypherpunks repositories - gostls13.git/commit
text/template: verify that names in FuncMap are valid identifiers
authorRob Pike <r@golang.org>
Mon, 14 Sep 2015 18:27:20 +0000 (11:27 -0700)
committerRob Pike <r@golang.org>
Tue, 15 Sep 2015 16:09:55 +0000 (16:09 +0000)
commitdbfd9085d61b4469ab8a4aba8e71e5905d45f495
treef74bf1e62e44f6a222bbca346c0aa2e97296b2ea
parent211cdf1e004b35e817935537671f9577066800df
text/template: verify that names in FuncMap are valid identifiers

There was no verification in Funcs that the map had valid names,
which meant that the error could only be caught when parsing
the template that tried to use them. Fix this by validating the names
in Funcs and panicking before parsing if there is a bad name.

This is arguably an API change, since it didn't trigger a panic
before, but Funcs did already panic if the function itself was no
good, so I argue it's an acceptable change to add more sanity
checks.

Fixes #9685.

Change-Id: Iabf1d0602c49d830f3ed71ca1ccc7eb9a5521ff5
Reviewed-on: https://go-review.googlesource.com/14562
Reviewed-by: Andrew Gerrand <adg@golang.org>
src/text/template/exec_test.go
src/text/template/funcs.go
src/text/template/template.go