Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/private/Comments/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function getMentions(bool $supportMarkdown = true): array {
$message = $this->getMessage();
if ($supportMarkdown) {
// Strip fenced code blocks and inline code so mentions inside them are ignored
$message = preg_replace('/^```.*?^```|^~~~.*?^~~~/sm', '', $message);
$message = preg_replace('/^```.*?(^```|\z)|^~~~.*?(^~~~|\z)/sm', '', $message);
$message = preg_replace('/`[^`\n]*`/', '', $message);
}

Expand Down
12 changes: 12 additions & 0 deletions tests/lib/Comments/CommentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,18 @@ public static function mentionsProvider(): array {
null,
false,
],
[
'Mention @alice and `also @bob as end of text only applies to code blocks',
[['type' => 'user', 'id' => 'alice'], ['type' => 'user', 'id' => 'bob']],
],
[
"Mention @alice but not in unclosed fenced code block\n```\n@bob\n@charlie",
[['type' => 'user', 'id' => 'alice']],
],
[
"Mention @alice but not in unclosed tilde code block\n~~~\n@bob",
[['type' => 'user', 'id' => 'alice']],
],
];
}

Expand Down
Loading