Test the Template regex and disable the template if it is invalid. Fixes #361
This commit is contained in:
parent
eeed0b04f6
commit
2ff0a10901
@ -38,7 +38,11 @@ class Template
|
||||
// @todo Make sure we have a structural objectclass, or make the template invalid
|
||||
$this->template = collect(json_decode($td->get($file),null,512,JSON_OBJECT_AS_ARRAY|JSON_THROW_ON_ERROR));
|
||||
|
||||
} catch (\JsonException $e) {
|
||||
// Also test the regex is valid.
|
||||
if ($this->template->has('regexp'))
|
||||
preg_match($this->regexp,'');
|
||||
|
||||
} catch (\ErrorException|\JsonException $e) {
|
||||
$this->invalid = TRUE;
|
||||
$this->reason = $e->getMessage();
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class Entry extends Model
|
||||
$to = new Template($file);
|
||||
|
||||
if ($to->invalid) {
|
||||
Log::debug(sprintf('Template [%s] is not valid (%s) - ignoring',$file,$to->reason));
|
||||
Log::alert(sprintf('Template [%s] is not valid (%s) - ignoring',$file,$to->reason));
|
||||
|
||||
} else {
|
||||
$templates->put($file,new Template($file));
|
||||
|
Loading…
x
Reference in New Issue
Block a user