text/template: access to methods that are not part of interface #35198
Comments
Have you been able to verify if old versions of Go behave differently here? If so, could you use a |
I've found this question on Stack Overflow that indicates that it was different. The code listed in the answer there was removed in 167a712, and checked for an empty Apart from how older versions behaved, it's weird to explicitly pass an interface as data to a template and see it being ignored and the underlying type used instead. It could even be a security issue, as templates have access to more than was intended. (The |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I executed a
text/template.Template
with an interface as data.Example code
On play: https://play.golang.org/p/YgMyBPie8kw
What did you expect to see?
My template is using functions that don't exist in the interface, thus I was expecting an error.
What did you see instead?
The template is able to execute functions on the underlying type, exposing functionality I don't want to expose.
I believe the
text/template
package actually behaved as I would expect in the past. I think the functionality was changed in 167a712.The text was updated successfully, but these errors were encountered: