diff --git a/lib/private/Comments/Comment.php b/lib/private/Comments/Comment.php index 94c43be622..76c6e1d1f6 100644 --- a/lib/private/Comments/Comment.php +++ b/lib/private/Comments/Comment.php @@ -225,14 +225,14 @@ class Comment implements IComment { * */ public function getMentions() { - $ok = preg_match_all("/\B(?getMessage(), $mentions); + $ok = preg_match_all("/\B(?getMessage(), $mentions); if(!$ok || !isset($mentions[0]) || !is_array($mentions[0])) { return []; } $uids = array_unique($mentions[0]); $result = []; foreach ($uids as $uid) { - $result[] = ['type' => 'user', 'id' => substr($uid, 1)]; + $result[] = ['type' => 'user', 'id' => trim(substr($uid, 1), '"')]; } return $result; } diff --git a/tests/lib/Comments/CommentTest.php b/tests/lib/Comments/CommentTest.php index 15dd9120e4..5fb19396d8 100644 --- a/tests/lib/Comments/CommentTest.php +++ b/tests/lib/Comments/CommentTest.php @@ -150,8 +150,11 @@ class CommentTest extends TestCase { ['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'] - ] + '@@chef is also a valid mention, no matter how strange it looks', ['@chef'] + ], + [ + 'Also @"user with spaces" are now supported', ['user with spaces'] + ], ]; }