Add JavaScript support for a024d6a4
authorMatthias Schmidt <gravatronics@live.com>
Wed, 3 Dec 2014 18:29:18 +0000 (19:29 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 3 Dec 2014 18:29:18 +0000 (19:29 +0100)
wcfsetup/install/files/js/WCF.Message.js

index c2ae4f5b1316bc51e5c62004246c7d13adbd5e1e..450b50f94b29c45553a2b33bd4f02b94ada32551 100644 (file)
@@ -3627,16 +3627,23 @@ WCF.Message.UserMention = Class.extend({
                // remove unicode zero width space and non-breaking space
                var $textBackup = $text;
                $text = '';
+               var $hadSpace = false;
                for (var $i = 0; $i < $textBackup.length; $i++) {
                        var $byte = $textBackup.charCodeAt($i).toString(16);
-                       if ($byte != '200b' && !/\s/.test($textBackup[$i])) {
+                       if ($byte != '200b' && (!/\s/.test($textBackup[$i]) || (($byte == 'a0' || $byte == '20') && !$hadSpace))) {
+                               if ($byte == 'a0' || $byte == '20') {
+                                       $hadSpace = true;
+                               }
+                               
                                if ($textBackup[$i] === '@' && $i && /\s/.test($textBackup[$i - 1])) {
+                                       $hadSpace = false;
                                        $text = '';
                                }
                                
                                $text += $textBackup[$i];
                        }
                        else {
+                               $hadSpace = false;
                                $text = '';
                        }
                }