Fixed infinite loop during mention parsing
authorAlexander Ebert <ebert@woltlab.com>
Thu, 17 Nov 2016 11:49:34 +0000 (12:49 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 17 Nov 2016 11:50:11 +0000 (12:50 +0100)
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeTextParser.class.php

index 7894724c60e8f1c11bee04c3857397ef606d3749..b466393a214acbe1439b02b3b02d72a1da6d8b8d 100644 (file)
@@ -309,9 +309,10 @@ class HtmlInputNodeTextParser {
                }
                
                foreach ($users as $userID => $username) {
+                       $offset = 0;
                        do {
                                $needle = '@' . $username;
-                               $pos = mb_stripos($value, $needle);
+                               $pos = mb_stripos($value, $needle, $offset);
                                
                                // username not found, maybe it is quoted
                                if ($pos === false) {
@@ -331,6 +332,8 @@ class HtmlInputNodeTextParser {
                                        // and we need to replace them one by one, also avoiding only replacing
                                        // the non-quoted username even though both variants are present
                                        $value = preg_replace('~' . preg_quote($needle, '~') . '~i', $marker, $value, 1);
+                                       
+                                       $offset = $pos + 1;
                                }
                        }
                        while ($pos);