ref: be190fdb0d43592a3c8304fa4a1919a685e10b72
parent: be017f187e7c9beac6baabdba32bdb5753f9b4d4
author: bep <[email protected]>
date: Thu Apr 30 07:41:25 EDT 2015
tpl: check for too many arguments in apply Fixes #1091
--- a/tpl/template_funcs.go
+++ b/tpl/template_funcs.go
@@ -668,6 +668,8 @@
if len(args) < num {
return reflect.ValueOf(nil), errors.New("Too few arguments")
+ } else if len(args) > num {
+ return reflect.ValueOf(nil), errors.New("Too many arguments")
}
res := fn.Call(n)
--- a/tpl/template_test.go
+++ b/tpl/template_test.go
@@ -15,7 +15,9 @@
// Issue #1089
{"{{apply .C \"first\" }}", 2},
// Issue #1090
- {"{{ slicestr \"000000\" 10}}", 2}} {
+ {"{{ slicestr \"000000\" 10}}", 2},
+ // Issue #1091
+ {"{{apply .C \"first\" 0 0 0}}", 2}} {
templ := New()
d := &Data{