From: Alexander Ebert Date: Mon, 18 Jul 2016 14:28:09 +0000 (+0200) Subject: Properly passing bbcode's source for reversal X-Git-Tag: 3.0.0_Beta_1~1049 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6896301b43a8081bfa1c96bde8e17a71fcf591f9;p=GitHub%2FWoltLab%2FWCF.git Properly passing bbcode's source for reversal --- diff --git a/wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php b/wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php index de926a6e54..c5b1ba57cc 100644 --- a/wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php @@ -359,7 +359,7 @@ class HtmlBBCodeParser extends BBCodeParser { $attributes = ' data-attributes="' . base64_encode(JSON::encode($tag['attributes'])) . '"'; } - return ''; + return ''; } /** @@ -381,7 +381,7 @@ class HtmlBBCodeParser extends BBCodeParser { return ''; } - return ''; + 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 0ef1557801..11a3efacd9 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 @@ -88,6 +88,7 @@ class MessageHtmlInputFilter implements IHtmlInputFilter { $definition->addElement('woltlab-metacode-marker', 'Inline', 'Empty', '', [ 'data-attributes' => 'Text', 'data-name' => 'Text', + 'data-source' => '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 fd01b19530..d8577a335c 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 @@ -129,6 +129,7 @@ class HtmlInputNodeWoltlabMetacodeMarker extends AbstractHtmlInputNode { $attributes = $element->getAttribute('data-attributes'); $name = $element->getAttribute('data-name'); $uuid = $element->getAttribute('data-uuid'); + $source = @base64_decode($element->getAttribute('data-source')); if (!isset($pairs[$uuid])) { $pairs[$uuid] = [ @@ -143,9 +144,11 @@ class HtmlInputNodeWoltlabMetacodeMarker extends AbstractHtmlInputNode { $pairs[$uuid]['attributes'] = $attributes; $pairs[$uuid]['name'] = $name; $pairs[$uuid]['open'] = $element; + $pairs[$uuid]['openSource'] = $source; } else { $pairs[$uuid]['close'] = $element; + $pairs[$uuid]['closeSource'] = $source; } } @@ -194,7 +197,9 @@ class HtmlInputNodeWoltlabMetacodeMarker extends AbstractHtmlInputNode { $groups[$name][] = [ 'attributes' => $data['attributes'], 'close' => $data['close'], - 'open' => $data['open'] + 'closeSource' => $data['closeSource'], + 'open' => $data['open'], + 'openSource' => $data['openSource'] ]; } @@ -430,11 +435,11 @@ class HtmlInputNodeWoltlabMetacodeMarker extends AbstractHtmlInputNode { $end = $pair['close']; $attributes = (isset($pair['attributes'])) ? $pair['attributes'] : ''; - $textNode = $start->ownerDocument->createTextNode(HtmlBBCodeParser::getInstance()->buildBBCodeTag($name, $attributes, true)); + $textNode = $start->ownerDocument->createTextNode(($pair['openSource']) ?: HtmlBBCodeParser::getInstance()->buildBBCodeTag($name, $attributes, true)); DOMUtil::insertBefore($textNode, $start); DOMUtil::removeNode($start); - $textNode = $end->ownerDocument->createTextNode('[/' . $name . ']'); + $textNode = $end->ownerDocument->createTextNode(($pair['closeSource']) ?: '[/' . $name . ']'); DOMUtil::insertBefore($textNode, $end); DOMUtil::removeNode($end); }