From: Alexander Ebert Date: Sun, 16 Oct 2016 13:33:36 +0000 (+0200) Subject: Added additional metacode filter X-Git-Tag: 3.0.0_Beta_3~31 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=01ba60c7005d80c23a6c0405f43f826b034f29b4;p=GitHub%2FWoltLab%2FWCF.git Added additional metacode filter --- diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacodeMarker.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacodeMarker.class.php index 6cfa65a09e..d00e336e8c 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacodeMarker.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacodeMarker.class.php @@ -1,6 +1,7 @@ groupPairsByName($pairs); + $groups = $this->filterGroups($groups, $htmlNodeProcessor); + if (empty($groups)) { + return; + } + // convert source bbcode groups first to ensure no bbcodes inside // source blocks will be evaluated $groups = $this->convertSourceGroups($groups); @@ -71,6 +77,36 @@ class HtmlInputNodeWoltlabMetacodeMarker extends AbstractHtmlInputNode { $this->convertGroups($groups); } + /** + * Filters groups by reverting metacode markers for invalid bbcodes. + * + * @param array $groups grouped list of bbcode marker pairs + * @param AbstractHtmlNodeProcessor $htmlNodeProcessor node processor instance + * @return array filtered groups + */ + protected function filterGroups(array $groups, AbstractHtmlNodeProcessor $htmlNodeProcessor) { + /** @noinspection PhpUndefinedMethodInspection */ + $data = [ + 'context' => $htmlNodeProcessor->getContext(), + 'bbcodes' => array_keys($groups) + ]; + + EventHandler::getInstance()->fireAction($this, 'filterGroups', $data); + + foreach ($groups as $name => $pairs) { + if (!in_array($name, $data['bbcodes'])) { + foreach ($pairs as $pair) { + $pair['attributes'] = $htmlNodeProcessor->parseAttributes($pair['attributes']); + $this->convertToBBCode($name, $pair); + } + + unset($groups[$name]); + } + } + + return $groups; + } + /** * Transforms bbcode markers inside source code elements into their plain bbcode representation. *