Don't run nil funcs from magic map
This commit is contained in:
parent
c37abe9980
commit
fe16921713
|
@ -401,7 +401,7 @@ var VariablesMap map[string]bool = map[string]bool{
|
|||
func (a *Article) renderTemplateMagic(name string, params map[string]string) string {
|
||||
renderer, ok := MagicMap[name]
|
||||
text := ""
|
||||
if ok {
|
||||
if ok && renderer != nil {
|
||||
text = renderer(name, params)
|
||||
}
|
||||
|
||||
|
|
|
@ -54,3 +54,18 @@ func TestMagicMap(t *testing.T) {
|
|||
t.Error("Error in magic map ", l)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNilFunc(t *testing.T) {
|
||||
mw := "{{DISPLAYTITLE}}"
|
||||
t.Log(mw)
|
||||
|
||||
a, err := ParseArticle("Test", mw, &DummyPageGetter{})
|
||||
if err != nil {
|
||||
t.Error("Error:", err)
|
||||
}
|
||||
|
||||
l := a.GetText()
|
||||
if strings.TrimSpace(l) != "" {
|
||||
t.Error("NIL entry in magic map not caught", l)
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue