Do not crash in case of template parse error

databind
vitalif 2013-06-17 22:37:36 +00:00 committed by Vitaliy Filippov
parent 6e5062cfd1
commit 92dab3ce32
2 changed files with 11 additions and 0 deletions

View File

@ -178,6 +178,12 @@ class VMXTemplateCompiler
$this->lexer->set_code($code);
$this->lexer->feed($this->parser);
if ($this->st->functions['main']['body'] === '')
{
// Parse error
unset($this->st->functions['main']);
}
// Generate code for functions
$code = '';
foreach ($this->st->functions as $f)

View File

@ -297,6 +297,11 @@ class VMXTemplate
}
}
}
if (!isset($class::$functions[$func]))
{
$this->options->error("No function '$func' found in template $fn", true);
return NULL;
}
$func = "fn_$func";
$tpl = new $class($this);
if ($vars)