mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 20:10:55 +01:00
Stop all object mentions from matching after "@"
Summary: Fixes T9479. Currently, `@aaaaaaaa` may try to match as a commit hash, and `@C123456` may try to match as a Countdown reference. These should only match as user mentions. Prevent object mention rules from matching after `@`. We already prevent them after `-` and `#`, and already prevented the username rule after `@` (i.e., preventing `@@user`). Test Plan: Created some "interesting" users locally and `@mentioned` them: {F850779} Reviewers: chad Reviewed By: chad Maniphest Tasks: T9479 Differential Revision: https://secure.phabricator.com/D14186
This commit is contained in:
parent
21021b55c4
commit
fa943f744b
2 changed files with 23 additions and 3 deletions
|
@ -121,6 +121,25 @@ final class DiffusionCommitRemarkupRuleTestCase extends PhabricatorTestCase {
|
|||
),
|
||||
),
|
||||
),
|
||||
|
||||
// After an "@", we should not be recognizing references because these
|
||||
// are username mentions.
|
||||
'deadbeef' => array(
|
||||
'embed' => array(
|
||||
),
|
||||
'ref' => array(
|
||||
array(
|
||||
'offset' => 0,
|
||||
'id' => 'deadbeef',
|
||||
),
|
||||
),
|
||||
),
|
||||
'@deadbeef' => array(
|
||||
'embed' => array(
|
||||
),
|
||||
'ref' => array(
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($cases as $input => $expect) {
|
||||
|
|
|
@ -209,13 +209,14 @@ abstract class PhabricatorObjectRemarkupRule extends PhutilRemarkupRule {
|
|||
$boundary = '\\B';
|
||||
}
|
||||
|
||||
// The "(?<![#-])" prevents us from linking "#abcdef" or similar, and
|
||||
// "ABC-T1" (see T5714).
|
||||
// The "(?<![#@-])" prevents us from linking "#abcdef" or similar, and
|
||||
// "ABC-T1" (see T5714), and from matching "@T1" as a task (it is a user)
|
||||
// (see T9479).
|
||||
|
||||
// The "\b" allows us to link "(abcdef)" or similar without linking things
|
||||
// in the middle of words.
|
||||
|
||||
return '((?<![#-])'.$boundary.$prefix.'('.$id.')(?:#([-\w\d]+))?(?!\w))u';
|
||||
return '((?<![#@-])'.$boundary.$prefix.'('.$id.')(?:#([-\w\d]+))?(?!\w))u';
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue