Skip to content

Commit

Permalink
Match mentions when the username is wrapped in quotes
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Oct 15, 2018
1 parent 8177fdb commit 650c53f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/private/Comments/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,14 @@ public function setMessage($message) {
*
*/
public function getMentions() {
$ok = preg_match_all("/\B(?<![^a-z0-9_\-@\.\'\s])@[a-z0-9_\-@\.\']+/i", $this->getMessage(), $mentions);
$ok = preg_match_all("/\B(?<![^a-z0-9_\-@\.\'\s])@(\"[a-z0-9_\-@\.\' ]+\"|[a-z0-9_\-@\.\']+)/i", $this->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;
}
Expand Down

0 comments on commit 650c53f

Please sign in to comment.