@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+23 -3
+19
src/applications/diffusion/remarkup/__tests__/DiffusionCommitRemarkupRuleTestCase.php
··· 121 121 ), 122 122 ), 123 123 ), 124 + 125 + // After an "@", we should not be recognizing references because these 126 + // are username mentions. 127 + 'deadbeef' => array( 128 + 'embed' => array( 129 + ), 130 + 'ref' => array( 131 + array( 132 + 'offset' => 0, 133 + 'id' => 'deadbeef', 134 + ), 135 + ), 136 + ), 137 + '@deadbeef' => array( 138 + 'embed' => array( 139 + ), 140 + 'ref' => array( 141 + ), 142 + ), 124 143 ); 125 144 126 145 foreach ($cases as $input => $expect) {
+4 -3
src/infrastructure/markup/rule/PhabricatorObjectRemarkupRule.php
··· 209 209 $boundary = '\\B'; 210 210 } 211 211 212 - // The "(?<![#-])" prevents us from linking "#abcdef" or similar, and 213 - // "ABC-T1" (see T5714). 212 + // The "(?<![#@-])" prevents us from linking "#abcdef" or similar, and 213 + // "ABC-T1" (see T5714), and from matching "@T1" as a task (it is a user) 214 + // (see T9479). 214 215 215 216 // The "\b" allows us to link "(abcdef)" or similar without linking things 216 217 // in the middle of words. 217 218 218 - return '((?<![#-])'.$boundary.$prefix.'('.$id.')(?:#([-\w\d]+))?(?!\w))u'; 219 + return '((?<![#@-])'.$boundary.$prefix.'('.$id.')(?:#([-\w\d]+))?(?!\w))u'; 219 220 } 220 221 221 222