From: Alexander Ebert Date: Mon, 29 Aug 2016 09:52:56 +0000 (+0200) Subject: Properly handling bbcodes with content being treated as source X-Git-Tag: 3.0.0_Beta_1~418 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=208665db3f5e1cbf41ce414f7765b3c2e9e85f37;p=GitHub%2FWoltLab%2FWCF.git Properly handling bbcodes with content being treated as source --- diff --git a/wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php b/wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php index d7b314c37e..acddebcc22 100644 --- a/wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php @@ -323,16 +323,22 @@ class HtmlBBCodeParser extends BBCodeParser { * * @param string $name bbcode identifier * @param array $attributes list of attributes + * @param \DOMElement $element element * @return string parsed bbcode */ - public function getHtmlOutput($name, array $attributes) { + public function getHtmlOutput($name, array $attributes, \DOMElement $element) { if (isset($this->bbcodes[$name])) { + $bbcode = $this->bbcodes[$name]; + if ($bbcode->isSourceCode) { + array_unshift($attributes, $element->textContent); + } + $openingTag = ['attributes' => $attributes, 'name' => $name]; $closingTag = ['name' => $name]; - if ($this->bbcodes[$name]->getProcessor()) { + if ($bbcode->getProcessor()) { /** @var IBBCode $processor */ - $processor = $this->bbcodes[$name]->getProcessor(); + $processor = $bbcode->getProcessor(); return $processor->getParsedTag($openingTag, '', $closingTag, $this); } else { diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabMetacode.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabMetacode.class.php index 368c418e6b..eec7967800 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabMetacode.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabMetacode.class.php @@ -29,12 +29,14 @@ class HtmlOutputNodeWoltlabMetacode extends AbstractHtmlOutputNode { $attributes = $element->getAttribute('data-attributes'); $nodeIdentifier = StringUtil::getRandomID(); + + $element = $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier); + $htmlNodeProcessor->addNodeData($this, $nodeIdentifier, [ 'name' => $name, - 'attributes' => $htmlNodeProcessor->parseAttributes($attributes) + 'attributes' => $htmlNodeProcessor->parseAttributes($attributes), + 'element' => $element ]); - - $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier); } } @@ -44,6 +46,6 @@ class HtmlOutputNodeWoltlabMetacode extends AbstractHtmlOutputNode { public function replaceTag(array $data) { HtmlBBCodeParser::getInstance()->setOutputType($this->outputType); - return HtmlBBCodeParser::getInstance()->getHtmlOutput($data['name'], $data['attributes']); + return HtmlBBCodeParser::getInstance()->getHtmlOutput($data['name'], $data['attributes'], $data['element']); } }