From 9cb764f4e1bd0715f0b0a6ef4c899d26af809331 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 23 May 2022 16:01:28 +0200 Subject: [PATCH] Incorrect handling of HTML elements in `
`

Fixes #4824
---
 .../system/html/node/AbstractHtmlNodeProcessor.class.php | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/wcfsetup/install/files/lib/system/html/node/AbstractHtmlNodeProcessor.class.php b/wcfsetup/install/files/lib/system/html/node/AbstractHtmlNodeProcessor.class.php
index 93d263ab4c..32962cdb3a 100644
--- a/wcfsetup/install/files/lib/system/html/node/AbstractHtmlNodeProcessor.class.php
+++ b/wcfsetup/install/files/lib/system/html/node/AbstractHtmlNodeProcessor.class.php
@@ -89,14 +89,9 @@ abstract class AbstractHtmlNodeProcessor implements IHtmlNodeProcessor
         // fix the `
` linebreaks again
         $pres = $this->document->getElementsByTagName('pre');
         for ($i = 0, $length = $pres->length; $i < $length; $i++) {
-            /** @var \DOMElement $pre */
-            $pre = $pres->item($i);
             /** @var \DOMNode $node */
-            foreach ($pre->childNodes as $node) {
-                if (
-                    $node->nodeType === \XML_TEXT_NODE
-                    && \mb_strpos($node->textContent, '@@@WCF_PRE_LINEBREAK@@@') !== false
-                ) {
+            foreach ($this->getXPath()->query('./text()', $pres->item($i)) as $node) {
+                if (\str_contains($node->textContent, '@@@WCF_PRE_LINEBREAK@@@')) {
                     $node->nodeValue = \str_replace('@@@WCF_PRE_LINEBREAK@@@', "\n", $node->textContent);
                 }
             }
-- 
2.20.1