Fixed certain whitespaces causing the parser to fail
authorAlexander Ebert <ebert@woltlab.com>
Fri, 9 Sep 2016 21:21:23 +0000 (23:21 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 10 Sep 2016 15:12:15 +0000 (17:12 +0200)
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeTextParser.class.php

index ff4b3122656ab39a3f905efcc98c4f0d715856d1..2905f9a6c3c4da4e24661eb275671fd888d1b6ab 100644 (file)
@@ -142,7 +142,21 @@ class HtmlInputNodeTextParser {
                        /** @var \DOMText $node */
                        $node = $nodes[$i];
                        
-                       $this->detectMention($node, $node->textContent, $usernames);
+                       $oldValue = $value = $node->textContent;
+                       
+                       // this extra step ensures that we don't trip over some
+                       // random &nbsp; inserted by the editor and at the same
+                       // time gets rid of them afterwards
+                       $value = preg_replace('~\x{00A0}~u', ' ', $value);
+                       
+                       // zero-width whitespace causes a lot of issues and is not required 
+                       $value = preg_replace('~\x{200B}~u', '', $value);
+                       
+                       if ($value !== $oldValue) {
+                               $node->textContent = $value;
+                       }
+                       
+                       $this->detectMention($node, $value, $usernames);
                }
                
                $users = [];
@@ -159,11 +173,6 @@ class HtmlInputNodeTextParser {
                        $node = $nodes[$i];
                        $oldValue = $value = $node->textContent;
                        
-                       // this extra step ensures we don't trip over some random
-                       // &nbsp; inserted by the editor and at the same time
-                       // gets rid of them afterwards
-                       $value = preg_replace('~\x{00A0}~u', ' ', $value);
-                       
                        if (!empty($users)) {
                                $value = $this->parseMention($node, $value, $users);
                        }