From: Alexander Ebert Date: Mon, 18 Sep 2017 10:26:58 +0000 (+0200) Subject: Fixed `useText` reversal inside source bbcodes X-Git-Tag: 3.1.0_Alpha_4~5^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7d4e0bda1398fbd745e1dc471849abea1efc7215;p=GitHub%2FWoltLab%2FWCF.git Fixed `useText` reversal inside source bbcodes --- diff --git a/wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php b/wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php index a04f1224b4..4904ea631f 100644 --- a/wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php @@ -235,6 +235,7 @@ class HtmlBBCodeParser extends BBCodeParser { foreach ($this->bbcodes[$tag['name']]->getAttributes() as $attribute) { if ($attribute->useText && !isset($openingTag['attributes'][$attribute->attributeNo])) { $openingTag['attributes'][$attribute->attributeNo] = $buffer; + $openingTag['useText'] = $attribute->attributeNo; $hideBuffer = true; break; } @@ -428,6 +429,10 @@ class HtmlBBCodeParser extends BBCodeParser { // uses base64 encoding to avoid an "escape" nightmare $attributes = ' data-attributes="' . base64_encode(JSON::encode($tag['attributes'])) . '"'; + + if (isset($tag['useText'])) { + $attributes .= ' data-use-text="' . $tag['useText'] . '"'; + } } return ''; diff --git a/wcfsetup/install/files/lib/system/html/input/filter/MessageHtmlInputFilter.class.php b/wcfsetup/install/files/lib/system/html/input/filter/MessageHtmlInputFilter.class.php index ee50531390..86334d9fd4 100644 --- a/wcfsetup/install/files/lib/system/html/input/filter/MessageHtmlInputFilter.class.php +++ b/wcfsetup/install/files/lib/system/html/input/filter/MessageHtmlInputFilter.class.php @@ -108,6 +108,7 @@ class MessageHtmlInputFilter implements IHtmlInputFilter { 'data-attributes' => 'Text', 'data-name' => 'Text', 'data-source' => 'Text', + 'data-use-text' => 'Text', 'data-uuid' => 'Text' ]); 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 75704dd3be..f76dd3c59f 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 @@ -195,6 +195,7 @@ class HtmlInputNodeWoltlabMetacodeMarker extends AbstractHtmlInputNode { $pairs[$uuid]['name'] = $name; $pairs[$uuid]['open'] = $element; $pairs[$uuid]['openSource'] = $source; + $pairs[$uuid]['useText'] = ($element->hasAttribute('data-use-text')) ? $element->getAttribute('data-use-text') : false; } else { $pairs[$uuid]['close'] = $element; @@ -249,7 +250,8 @@ class HtmlInputNodeWoltlabMetacodeMarker extends AbstractHtmlInputNode { 'close' => $data['close'], 'closeSource' => $data['closeSource'], 'open' => $data['open'], - 'openSource' => $data['openSource'] + 'openSource' => $data['openSource'], + 'useText' => $data['useText'] ]; } @@ -526,8 +528,13 @@ class HtmlInputNodeWoltlabMetacodeMarker extends AbstractHtmlInputNode { /** @var \DOMElement $end */ $end = $pair['close']; - $attributes = isset($pair['attributes']) ? $pair['attributes'] : ''; - $textNode = $start->ownerDocument->createTextNode($pair['openSource'] ?: HtmlBBCodeParser::getInstance()->buildBBCodeTag($name, $attributes, true)); + $attributes = isset($pair['attributes']) ? $pair['attributes'] : []; + $content = ''; + if (isset($pair['useText']) && isset($attributes[$pair['useText']])) { + $content = array_splice($attributes, $pair['useText'])[0]; + } + + $textNode = $start->ownerDocument->createTextNode(($pair['openSource'] ?: HtmlBBCodeParser::getInstance()->buildBBCodeTag($name, $attributes, true)) . $content); DOMUtil::insertBefore($textNode, $start); DOMUtil::removeNode($start);