From f065414031df73873dddeea7892fea8a7b9cb6a6 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 28 Sep 2016 13:16:33 +0200 Subject: [PATCH] working around a libxml bug --- .../input/filter/MessageHtmlInputFilter.class.php | 12 +++++++++++- .../html/node/AbstractHtmlNodeProcessor.class.php | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/html/input/filter/MessageHtmlInputFilter.class.php b/wcfsetup/install/files/lib/system/html/input/filter/MessageHtmlInputFilter.class.php index 22ce9eaab1..b03b0cf370 100644 --- a/wcfsetup/install/files/lib/system/html/input/filter/MessageHtmlInputFilter.class.php +++ b/wcfsetup/install/files/lib/system/html/input/filter/MessageHtmlInputFilter.class.php @@ -24,7 +24,17 @@ class MessageHtmlInputFilter implements IHtmlInputFilter { * @return string sanitized HTML */ public function apply($html) { - return $this->getPurifier()->purify($html); + // work-around for a libxml bug that causes a single space between + // some inline elements to be dropped + $html = str_replace('> <', '><', $html); + + $html = $this->getPurifier()->purify($html); + + // work-around for a libxml bug that causes a single space between + // some inline elements to be dropped + $html = preg_replace('~>\x{E000}\x{EFFF}\x{E000}<~u', '> <', $html); + + return $html; } /** 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 5c5cdaf5af..205756728b 100644 --- a/wcfsetup/install/files/lib/system/html/node/AbstractHtmlNodeProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/node/AbstractHtmlNodeProcessor.class.php @@ -56,6 +56,10 @@ abstract class AbstractHtmlNodeProcessor implements IHtmlNodeProcessor { // strip UTF-8 zero-width whitespace $html = preg_replace('~\x{200B}~u', '', $html); + // work-around for a libxml bug that causes a single space between + // some inline elements to be dropped + $html = str_replace('> <', '><', $html); + // Ignore all errors when loading the HTML string, because DOMDocument does not // provide a proper way to add custom HTML elements (even though explicitly allowed // in HTML5) and the input HTML has already been sanitized by HTMLPurifier. @@ -96,6 +100,10 @@ abstract class AbstractHtmlNodeProcessor implements IHtmlNodeProcessor { } + // work-around for a libxml bug that causes a single space between + // some inline elements to be dropped + $html = preg_replace('~>\x{E000}\x{EFFF}\x{E000}<~u', '> <', $html); + return $html; } -- 2.20.1