Fixed smilies being recognized as images
authorAlexander Ebert <ebert@woltlab.com>
Thu, 15 Sep 2016 14:49:03 +0000 (16:49 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 15 Sep 2016 15:18:10 +0000 (17:18 +0200)
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeImg.class.php

index e08490332c8139c21175b5dbc82c55e9958faa91..d0698d47ec4f6bbf71d6af41667e0f3e82f6ff06 100644 (file)
@@ -26,7 +26,27 @@ class HtmlInputNodeImg extends AbstractHtmlInputNode {
         * @inheritDoc
         */
        public function isAllowed(AbstractHtmlNodeProcessor $nodeProcessor) {
-               return BBCodeHandler::getInstance()->isAvailableBBCode('img') ? [] : ['img'];
+               if (BBCodeHandler::getInstance()->isAvailableBBCode('img')) {
+                       return [];
+               }
+               
+               $foundImage = false;
+               
+               // check if there are only attachments, media or smilies
+               /** @var \DOMElement $element */
+               foreach ($nodeProcessor->getDocument()->getElementsByTagName('img') as $element) {
+                       $class = $element->getAttribute('class');
+                       if (!preg_match('~\b(?:woltlabAttachment|woltlabSuiteMedia|smiley)\b~', $class)) {
+                               $foundImage = true;
+                               break;
+                       }
+               }
+               
+               if (!$foundImage) {
+                       return [];
+               }
+               
+               return ['img'];
        }
        
        /**