diff options
-rw-r--r-- | lib/private/Comments/Comment.php | 2 | ||||
-rw-r--r-- | tests/lib/Comments/CommentTest.php | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/lib/private/Comments/Comment.php b/lib/private/Comments/Comment.php index dd790c2e50a..94c43be622b 100644 --- a/lib/private/Comments/Comment.php +++ b/lib/private/Comments/Comment.php @@ -225,7 +225,7 @@ class Comment implements IComment { * */ public function getMentions() { - $ok = preg_match_all('/\B@[a-z0-9_\-@\.\']+/i', $this->getMessage(), $mentions); + $ok = preg_match_all("/\B(?<![^a-z0-9_\-@\.\'\s])@[a-z0-9_\-@\.\']+/i", $this->getMessage(), $mentions); if(!$ok || !isset($mentions[0]) || !is_array($mentions[0])) { return []; } diff --git a/tests/lib/Comments/CommentTest.php b/tests/lib/Comments/CommentTest.php index 6f67356ccae..15dd9120e44 100644 --- a/tests/lib/Comments/CommentTest.php +++ b/tests/lib/Comments/CommentTest.php @@ -144,10 +144,14 @@ class CommentTest extends TestCase { [ '@foobar and @barfoo you should know, @foo@bar.com is valid' . ' and so is @bar@foo.org@foobar.io I hope that clarifies everything.' . - ' cc @23452-4333-54353-2342 @yolo!', + ' cc @23452-4333-54353-2342 @yolo!' . + ' however the most important thing to know is that www.croissant.com/@oil is not valid' . + ' and won\'t match anything at all', ['foobar', 'barfoo', 'foo@bar.com', 'bar@foo.org@foobar.io', '23452-4333-54353-2342', 'yolo'] + ], + [ + '@@chef is also a valid mention, no matter how strange it looks', ['@chef'] ] - ]; } |