From: Alexander Ebert Date: Thu, 19 Jan 2017 12:05:30 +0000 (+0100) Subject: Improved `
` linebreak fix
X-Git-Tag: 3.0.1~8
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6bab821ca7f4c72236b593d25bc1da44f0760a99;p=GitHub%2FWoltLab%2FWCF.git

Improved `
` linebreak fix
---

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 8c90684a15..fa7d012de3 100644
--- a/wcfsetup/install/files/lib/system/html/node/AbstractHtmlNodeProcessor.class.php
+++ b/wcfsetup/install/files/lib/system/html/node/AbstractHtmlNodeProcessor.class.php
@@ -76,6 +76,19 @@ abstract class AbstractHtmlNodeProcessor implements IHtmlNodeProcessor {
 		// would conflict with already existing entities when reverting them.
 		@$this->document->loadHTML('' . $html . '');
 		
+		// fix the `
` linebreaks again
+		$pres = $this->document->getElementsByTagName('pre');
+		for ($i = 0, $length = $pres->length; $i < $length; $i++) {
+			/** @var \DOMElement $pre */
+			$pre = $pres[$i];
+			/** @var \DOMNode $node */
+			foreach ($pre->childNodes as $node) {
+				if ($node->nodeType === XML_TEXT_NODE && mb_strpos($node->textContent, '@@@WCF_PRE_LINEBREAK@@@') !== false) {
+					$node->nodeValue = str_replace('@@@WCF_PRE_LINEBREAK@@@', "\n", $node->textContent);
+				}
+			}
+		}
+		
 		$this->nodeData = [];
 	}
 	
@@ -108,9 +121,6 @@ abstract class AbstractHtmlNodeProcessor implements IHtmlNodeProcessor {
 			
 		}
 		
-		// restore line breaks inside code
-		$html = str_replace('@@@WCF_PRE_LINEBREAK@@@', "\n", $html);
-		
 		// work-around for a libxml bug that causes a single space between
 		// some inline elements to be dropped
 		$html = str_replace(' ', ' ', $html);