Fix fatal error when widget code contains invalid XML

This commit is contained in:
Kijin Sung 2021-05-17 20:06:46 +09:00
parent 7f3f50b851
commit f0df00a82d

View file

@ -273,8 +273,13 @@ class widgetController extends widget
*/
function transWidget($matches)
{
$vars = new stdClass;
$xml = simplexml_load_string(trim($matches[0]));
if ($xml === false)
{
return '<div>Invalid XML in widget code.</div>';
}
$vars = new stdClass;
foreach ($xml->img ? $xml->img->attributes() : $xml->attributes() as $key => $val)
{
$vars->{$key} = strval($val);