File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -198,8 +198,8 @@ public function getMentions(bool $supportMarkdown = true): array {
198198 $ message = $ this ->getMessage ();
199199 if ($ supportMarkdown ) {
200200 // Strip fenced code blocks and inline code so mentions inside them are ignored
201- $ message = preg_replace ('/^```.*?^```|^~~~.*?^~~~/sm ' , '' , $ message );
202- $ message = preg_replace ('/`[^`\n]*` / ' , '' , $ message );
201+ $ message = preg_replace ('/^```.*?( ^```|\z)| ^~~~.*?( ^~~~|\z) /sm ' , '' , $ message );
202+ $ message = preg_replace ('/`[^`\n]*(`|\z) / ' , '' , $ message );
203203 }
204204
205205 $ ok = preg_match_all ("/\B(?<![^a-z0-9_\-@\.\'\s])@( \"(guest|email)\/[a-f0-9]+ \"| \"(?:federated_)?(?:group|team|user){1}\/[a-z0-9_\-@\.\' \/:]+ \"| \"[a-z0-9_\-@\.\' ]+ \"|[a-z0-9_\-@\.\']+)/i " , $ message , $ mentions );
Original file line number Diff line number Diff line change @@ -240,6 +240,22 @@ public static function mentionsProvider(): array {
240240 null ,
241241 false ,
242242 ],
243+ [
244+ 'Mention @alice but not `@bob at end of line ' ,
245+ [['type ' => 'user ' , 'id ' => 'alice ' ]],
246+ ],
247+ [
248+ 'Mention @alice but not `Hello @bob at end of line ' ,
249+ [['type ' => 'user ' , 'id ' => 'alice ' ]],
250+ ],
251+ [
252+ "Mention @alice but not in unclosed fenced code block \n``` \n@bob \n@charlie " ,
253+ [['type ' => 'user ' , 'id ' => 'alice ' ]],
254+ ],
255+ [
256+ "Mention @alice but not in unclosed tilde code block \n~~~ \n@bob " ,
257+ [['type ' => 'user ' , 'id ' => 'alice ' ]],
258+ ],
243259 ];
244260 }
245261
You can’t perform that action at this time.
0 commit comments