mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
fix(comments): Correctly treat end of message as end of code block/inline
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
f8652506ac
commit
e305bab73f
2 changed files with 13 additions and 1 deletions
|
|
@ -198,7 +198,7 @@ class Comment implements IComment {
|
|||
$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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -240,6 +240,18 @@ class CommentTest extends TestCase {
|
|||
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']],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue