Fixed orphaned paragraphs w/ block bbcodes
authorAlexander Ebert <ebert@woltlab.com>
Mon, 21 Aug 2017 12:27:44 +0000 (14:27 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 21 Aug 2017 12:27:44 +0000 (14:27 +0200)
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacodeMarker.class.php

index 1d40f249fa2f7ce91b6e16528ca810e2a44f1fc7..dc42a86724f9af01983ea86308c935e04a06b7dc 100644 (file)
@@ -339,6 +339,14 @@ class HtmlInputNodeWoltlabMetacodeMarker extends AbstractHtmlInputNode {
                }
                while ($parent->nodeName === 'p' || !$this->isBlockElement($parent));
                
+               // block elements can sometimes contain a line break after the end tag
+               // which needs to be removed to avoid it being split into a separate p
+               if ($node = $end->nextSibling) {
+                       if ($node->nodeType === XML_TEXT_NODE && $node->textContent === "\n" || $node->textContent === "\r\n") {
+                               DOMUtil::removeNode($node);
+                       }
+               }
+               
                $element = DOMUtil::splitParentsUntil($start, $parent);
                if ($start !== $element) DOMUtil::insertBefore($start, $element);