Fixed empty spans not being stripped
authorAlexander Ebert <ebert@woltlab.com>
Sat, 7 Jan 2017 13:23:12 +0000 (14:23 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 7 Jan 2017 13:23:12 +0000 (14:23 +0100)
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeSpan.class.php

index d129187c88a36c66f81de05d520f797344edeb4c..ee1f92ecf05e1af7cccec031ef3b733e095cef6e 100644 (file)
@@ -121,6 +121,10 @@ class HtmlInputNodeProcessor extends AbstractHtmlNodeProcessor {
                        }
                        
                        $element->removeAttribute('class');
+                       
+                       if ($nodeName === 'span' && $element->attributes->length === 0) {
+                               DOMUtil::removeNode($element, true);
+                       }
                }
                
                EventHandler::getInstance()->fireAction($this, 'beforeEmbeddedProcess');
index 901dbb689b092b1fa6229f77576741d0f54ed7d0..7e4d55ec3ef3a71d2e32910b9795f0012d54a10b 100644 (file)
@@ -30,6 +30,10 @@ class HtmlInputNodeSpan extends AbstractHtmlInputNode {
        public function process(array $elements, AbstractHtmlNodeProcessor $htmlNodeProcessor) {
                /** @var \DOMElement $element */
                foreach ($elements as $element) {
+                       if (!$element->hasAttribute('style')) {
+                               continue;
+                       }
+                       
                        $style = explode(';', $element->getAttribute('style'));
                        for ($i = 0, $length = count($style); $i < $length; $i++) {
                                if (preg_match('~^\s*font-size\s*:(.+)$~', $style[$i], $matches)) {