Fixes the problem that the end node is inserted before the content
authorCyperghost <olaf_schmitz_1@t-online.de>
Fri, 6 Dec 2024 14:16:41 +0000 (15:16 +0100)
committerCyperghost <olaf_schmitz_1@t-online.de>
Fri, 6 Dec 2024 14:16:41 +0000 (15:16 +0100)
wcfsetup/install/files/lib/system/html/upcast/node/HtmlUpcastNodeWoltlabMetacode.class.php

index 18786e1a13a08999037ef70763ea488db9b4783a..a4146db96bb15627a221a7a071531bf316cc4c47 100644 (file)
@@ -111,21 +111,23 @@ final class HtmlUpcastNodeWoltlabMetacode extends AbstractHtmlUpcastNode
                         DOMUtil::removeNode($element, true);
                     }
                 } else {
-                    $insertNode = $element->parentNode->insertBefore(
+                    $element->parentNode->insertBefore(
                         $element->ownerDocument->createTextNode("[{$name}{$attributes}]"),
                         $element
                     );
+                    $endNode = $element->parentNode->insertBefore(
+                        $element->ownerDocument->createTextNode("[/{$name}]"),
+                        $element->nextSibling
+                    );
                     if ($bbcode->isSourceCode) {
-                        $insertNode->parentNode->appendChild(
-                            $element->ownerDocument->createTextNode($element->textContent)
+                        $endNode->parentNode->insertBefore(
+                            $element->ownerDocument->createTextNode($element->textContent),
+                            $endNode
                         );
                         DOMUtil::removeNode($element);
                     } else {
                         DOMUtil::removeNode($element, true);
                     }
-                    $insertNode->parentNode->appendChild(
-                        $element->ownerDocument->createTextNode("[/{$name}]")
-                    );
                 }
             }
         }