From 61464fa313853374c1f08afad9fcbd3c567699a3 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 13 Jan 2017 14:04:06 +0100 Subject: [PATCH] Fixed newlines inside `
` and non-breaking spaces

---
 .../html/node/AbstractHtmlNodeProcessor.class.php      | 10 ++++++++++
 1 file changed, 10 insertions(+)

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 34f88e3854..8c90684a15 100644
--- a/wcfsetup/install/files/lib/system/html/node/AbstractHtmlNodeProcessor.class.php
+++ b/wcfsetup/install/files/lib/system/html/node/AbstractHtmlNodeProcessor.class.php
@@ -53,9 +53,16 @@ abstract class AbstractHtmlNodeProcessor implements IHtmlNodeProcessor {
 		$this->document = new \DOMDocument('1.0', 'UTF-8');
 		$this->xpath = null;
 		
+		$html = preg_replace_callback('~(]*>)(.*?)(
)~s', function($matches) { + return $matches[1] . preg_replace('~\r?\n~', '@@@WCF_PRE_LINEBREAK@@@', $matches[2]) . $matches[3]; + }, $html); + // strip UTF-8 zero-width whitespace $html = preg_replace('~\x{200B}~u', '', $html); + // discard any non-breaking spaces + $html = str_replace(' ', ' ', $html); + // work-around for a libxml bug that causes a single space between // some inline elements to be dropped $html = str_replace('> <', '> <', $html); @@ -101,6 +108,9 @@ 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); -- 2.20.1