throw an exception on XML errors in eTemplates for easier fixing

This commit is contained in:
Ralf Becker 2021-02-16 17:38:47 +02:00
parent 4702d51e21
commit 81b4737710

View File

@ -123,7 +123,7 @@ class Widget
// read all attributes
$this->set_attrs($reader);
while($reader->read() && $reader->depth > $depth)
while(($ok=$reader->read()) && $reader->depth > $depth)
{
if ($reader->nodeType == XMLReader::ELEMENT && $reader->depth > $depth)
{
@ -135,6 +135,12 @@ class Widget
$this->attrs[(string)$reader->name] = (string)$reader->value;
}
}
// give a clear indication where the template error is
if (!$ok && ($error = libxml_get_last_error()))
{
$file = str_replace([EGW_SERVER_ROOT.'/', '//default/etemplates/'], '', $error->file);
throw new \Exception("Error passing XML file '$file' line $error->line: $error->message");
}
// Reset content as we leave
if($old_cont) {
@ -156,6 +162,7 @@ class Widget
}
else
{
libxml_use_internal_errors(true);
$reader = new XMLReader();
if (!$reader->XML($xml))
{