From 87db7c0371e4d39970c18fae864c93ef7c8e15f1 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Thu, 7 Jan 2021 11:16:26 +0900 Subject: [PATCH] Replace old XML parser with SimpleXML in widget controller --- modules/widget/widget.controller.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/modules/widget/widget.controller.php b/modules/widget/widget.controller.php index b8fb1078e..dfdbea057 100644 --- a/modules/widget/widget.controller.php +++ b/modules/widget/widget.controller.php @@ -261,9 +261,9 @@ class widgetController extends widget // Check whether to include information about editing $this->javascript_mode = $javascript_mode; // Widget code box change - $content = preg_replace_callback('!]*)widget=([^\>]*?)\>
(()*)!is', array($this,'transWidgetBox'), $content); + $content = preg_replace_callback('!]*)widget=([^>]*?)>
(()*)!is', array($this, 'transWidgetBox'), $content); // Widget code information byeogyeong - $content = preg_replace_callback('!]*)widget=([^\>]*?)\>!is', array($this,'transWidget'), $content); + $content = preg_replace_callback('!]*)widget=([^>]*?)>!is', array($this, 'transWidget'), $content); return $content; } @@ -273,16 +273,18 @@ class widgetController extends widget */ function transWidget($matches) { - $buff = trim($matches[0]); - - $oXmlParser = new XeXmlParser(); - $xml_doc = $oXmlParser->parse(trim($buff)); - - if($xml_doc->img) $vars = $xml_doc->img->attrs; - else $vars = $xml_doc->attrs; - + $vars = new stdClass; + $xml = simplexml_load_string(trim($matches[0])); + foreach ($xml->img ? $xml->img->attributes() : $xml->attributes() as $key => $val) + { + $vars->{$key} = strval($val); + } + $widget = $vars->widget; - if(!$widget) return $matches[0]; + if (!$widget) + { + return $matches[0]; + } unset($vars->widget); return $this->execute($widget, $vars, $this->javascript_mode);