Drop empty `data-attributes` for `<woltlab-metacode>` during input processing
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 16 May 2023 13:18:25 +0000 (15:18 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 16 May 2023 13:19:07 +0000 (15:19 +0200)
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php

index 84c9cffcecb041156b082e9baadb5d239e55d150..310f4f8044d2e254e08507643bc64b08a66d9ea8 100644 (file)
@@ -90,6 +90,13 @@ class HtmlInputNodeWoltlabMetacode extends AbstractHtmlInputNode
             }
 
             $attributes = $htmlNodeProcessor->parseAttributes($element->getAttribute('data-attributes'));
+            if ($attributes === []) {
+                // Drop the empty 'data-attributes' attribute. This saves some storage
+                // for common parameterless BBCodes and makes the edit history more useful.
+                // This change is safe, because a missing attribute will implicitly be
+                // considered to contain the empty string by ->getAttribute().
+                $element->removeAttribute('data-attributes');
+            }
 
             // check for converters
             $converter = $converters[$name] ?? null;