Fixed handling of `<td>`
authorAlexander Ebert <ebert@woltlab.com>
Thu, 22 Sep 2016 18:06:02 +0000 (20:06 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 22 Sep 2016 18:06:08 +0000 (20:06 +0200)
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php

index d841eeb6dccf4b2eb5077edf60f93924a4e87088..2cb79cbe92dd0317154dd52051c851871c530cce 100644 (file)
@@ -29,7 +29,12 @@ class HtmlInputNodeProcessor extends AbstractHtmlNodeProcessor {
                        // built-in
                        'smiley', 'woltlabAttachment', 'woltlabSuiteMedia'
                ],
-               'p' => [
+               'p' => 'text',
+               'td' => 'text',
+               
+               // not a valid tag, used for elements that are used to wrap text
+               // content such as <p> or <td>, avoid duplicate declarations
+               'text' => [
                        // text alignment
                        'text-center', 'text-justify', 'text-right',
                        
@@ -95,13 +100,16 @@ class HtmlInputNodeProcessor extends AbstractHtmlNodeProcessor {
                
                // strip invalid class names
                /** @var \DOMElement $element */
-               $before = htmlentities($this->getHtml());
                foreach ($this->getXPath()->query('//*[@class]') as $element) {
                        $nodeName = $element->nodeName;
                        if (isset(self::$allowedClassNames[$nodeName])) {
                                $classNames = explode(' ', $element->getAttribute('class'));
                                $classNames = array_filter($classNames, function ($className) use ($nodeName) {
-                                       return  ($className && in_array($className, self::$allowedClassNames[$nodeName]));
+                                       if (self::$allowedClassNames[$nodeName] === 'text') {
+                                               return ($className && in_array($className, self::$allowedClassNames['text']));
+                                       }
+                                       
+                                       return ($className && in_array($className, self::$allowedClassNames[$nodeName]));
                                });
                                
                                if (!empty($classNames)) {