Fixed `useText` handling of bbcode attributes
authorAlexander Ebert <ebert@woltlab.com>
Fri, 15 Sep 2017 09:14:35 +0000 (11:14 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 15 Sep 2017 09:14:35 +0000 (11:14 +0200)
Fixes #2425

wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php

index 3271d85e75085ba27ab3390e1997b9be1d836301..a04f1224b456a1edeb0c28eade98095cb1241c0b 100644 (file)
@@ -231,11 +231,13 @@ class HtmlBBCodeParser extends BBCodeParser {
                                if ($openingTag && $openingTag['name'] == $tag['name']) {
                                        $hideBuffer = false;
                                        // insert buffered content as attribute value
-                                       foreach ($this->bbcodes[$tag['name']]->getAttributes() as $attribute) {
-                                               if ($attribute->useText && !isset($openingTag['attributes'][$attribute->attributeNo])) {
-                                                       $openingTag['attributes'][$attribute->attributeNo] = $buffer;
-                                                       $hideBuffer = true;
-                                                       break;
+                                       if (!empty($buffer)) {
+                                               foreach ($this->bbcodes[$tag['name']]->getAttributes() as $attribute) {
+                                                       if ($attribute->useText && !isset($openingTag['attributes'][$attribute->attributeNo])) {
+                                                               $openingTag['attributes'][$attribute->attributeNo] = $buffer;
+                                                               $hideBuffer = true;
+                                                               break;
+                                                       }
                                                }
                                        }
                                        
@@ -243,7 +245,7 @@ class HtmlBBCodeParser extends BBCodeParser {
                                        if ($this->isValidTag($openingTag)) {
                                                if ($this->bbcodes[$tag['name']]->className) {
                                                        // difference to the original implementation: use the custom HTML element than to process them directly
-                                                       $parsedTag = $this->compileTag($openingTag, $buffer, $tag);
+                                                       $parsedTag = $this->compileTag($openingTag, ($hideBuffer ? '' : $buffer), $tag);
                                                }
                                                else {
                                                        // build tag