Removed cleanup again, it leads to false-positives
authorAlexander Ebert <ebert@woltlab.com>
Fri, 2 Sep 2016 10:25:32 +0000 (12:25 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 2 Sep 2016 10:25:32 +0000 (12:25 +0200)
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php

index 3dc10092d2e5bbee2bcceb078b01b3ff1f8003d8..1a121ed868a4ae520a7b7d06afb7aa67969ee248 100644 (file)
@@ -58,8 +58,6 @@ class HtmlInputNodeProcessor extends AbstractHtmlNodeProcessor {
                $this->processEmbeddedContent();
                
                EventHandler::getInstance()->fireAction($this, 'afterProcess');
-               
-               $this->cleanup();
        }
        
        /**
@@ -245,49 +243,6 @@ class HtmlInputNodeProcessor extends AbstractHtmlNodeProcessor {
                EventHandler::getInstance()->fireAction($this, 'parseEmbeddedContent');
        }
        
-       /**
-        * Removes garbage left in the DOM.
-        */
-       protected function cleanup() {
-               // remove empty <p> tags
-               $elements = [];
-               foreach ($this->getDocument()->getElementsByTagName('p') as $element) {
-                       $elements[] = $element;
-               }
-               
-               /** @var \DOMElement $element */
-               foreach ($elements as $element) {
-                       if ($element->hasChildNodes()) {
-                               if ($element->childNodes->length === 1) {
-                                       /** @var \DOMNode $child */
-                                       $child = $element->childNodes[0];
-                                       if ($child->nodeType === XML_TEXT_NODE && empty(StringUtil::trim($element->childNodes[0]->textContent))) {
-                                               DOMUtil::removeNode($element);
-                                       }
-                               }
-                       }
-                       else {
-                               DOMUtil::removeNode($element);
-                       }
-               }
-               
-               // remove <br> at the end of block elements
-               // without a succeeding non-empty paragraph
-               $elements = [];
-               foreach ($this->getDocument()->getElementsByTagName('br') as $element) {
-                       $elements[] = $element;
-               }
-               
-               $blocks = ['h1', 'h2', 'h3', 'p'];
-               foreach ($elements as $element) {
-                       if (in_array($element->parentNode->nodeName, $blocks)) {
-                               if ($element->previousSibling && !$element->nextSibling) {
-                                       DOMUtil::removeNode($element);
-                               }
-                       }
-               }
-       }
-       
        /**
         * Creates a new `<woltlab-metacode>` element contained in the same document
         * as the provided `$node`.