Improved detection of mentions
authorAlexander Ebert <ebert@woltlab.com>
Tue, 24 Feb 2015 21:03:08 +0000 (22:03 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 24 Feb 2015 21:03:08 +0000 (22:03 +0100)
wcfsetup/install/files/lib/system/bbcode/PreParser.class.php
wcfsetup/install/files/lib/system/event/listener/PreParserAtUserListener.class.php

index e0794aa1b9010a2f48ce804a172883d5a9cef8a0..dec6cc6d3e09de0ee002544d67ebbccec0b617f2 100644 (file)
@@ -180,7 +180,7 @@ class PreParser extends SingletonFactory {
                                (?:\[/\\2\])", Regex::DOT_ALL | Regex::IGNORE_WHITESPACE | Regex::CASE_INSENSITIVE);
                                
                                $callback = new Callback(function ($matches) {
-                                       return StringStack::pushToStringStack($matches[0], 'preParserCode');
+                                       return '['.StringStack::pushToStringStack(mb_substr($matches[0], 1, -1), 'preParserCode', "\0\0\0").']';
                                });
                        }
                        
@@ -219,7 +219,7 @@ class PreParser extends SingletonFactory {
                                (?:\[/\\1\])", Regex::DOT_ALL | Regex::IGNORE_WHITESPACE | Regex::CASE_INSENSITIVE);
                        
                        $callback = new Callback(function ($matches) {
-                               return StringStack::pushToStringStack($matches[0], 'urlBBCodes');
+                               return '['.StringStack::pushToStringStack(mb_substr($matches[0], 1, -1), 'preParserCode', "\0\0\0").']';
                        });
                }
                
index ae795a12329290fc2a129a79f88fe4cf0d683e35..ae79a0a4b3a32fc5efd771e209eb24a00432097d 100644 (file)
@@ -32,14 +32,14 @@ class PreParserAtUserListener implements IParameterizedEventListener {
                static $userRegex = null;
                if ($userRegex === null) {
                        $userRegex = new Regex("
-                               (?<=^|\s)                                       # either at start of string, or after whitespace
+                               (?:^|(?<=\s|\]))                                        # either at start of string, or after whitespace
                                @
                                (
                                        ([^',\s][^,\s]{2,})(?:\s[^,\s]+)?       # either at most two strings, not containing
                                                                                # whitespace or the comma, not starting with a single quote
                                                                                # separated by a single whitespace character
                                |
-                                       '(?:''|[^'])*'                          # or a string delimited by single quotes
+                                       '(?:''|[^']){3,}'                       # or a string delimited by single quotes
                                )
                        ", Regex::IGNORE_WHITESPACE);
                }