working around a libxml bug
authorAlexander Ebert <ebert@woltlab.com>
Wed, 28 Sep 2016 11:16:33 +0000 (13:16 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 28 Sep 2016 11:16:38 +0000 (13:16 +0200)
wcfsetup/install/files/lib/system/html/input/filter/MessageHtmlInputFilter.class.php
wcfsetup/install/files/lib/system/html/node/AbstractHtmlNodeProcessor.class.php

index 22ce9eaab18c1f9f22303952244fef47447a61d7..b03b0cf370e8d992087701c93c6e0e1afcc53ef6 100644 (file)
@@ -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('> <', '>&#xE000;&#xEFFF;&#xE000;<', $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;
        }
        
        /**
index 5c5cdaf5af598420fa7ff00c755380189f423c03..205756728ba6521786ee970e6b02916aa69d5e8a 100644 (file)
@@ -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('> <', '>&#xE000;&#xEFFF;&#xE000;<', $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;
        }