Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/markup/PhabricatorMentionRemarkupRule.php
<?php | <?php | ||||
final class PhabricatorMentionRemarkupRule extends PhutilRemarkupRule { | final class PhabricatorMentionRemarkupRule extends PhutilRemarkupRule { | ||||
const KEY_RULE_MENTION = 'rule.mention'; | const KEY_RULE_MENTION = 'rule.mention'; | ||||
const KEY_RULE_MENTION_ORIGINAL = 'rule.mention.original'; | const KEY_RULE_MENTION_ORIGINAL = 'rule.mention.original'; | ||||
const KEY_MENTIONED = 'phabricator.mentioned-user-phids'; | const KEY_MENTIONED = 'phabricator.mentioned-user-phids'; | ||||
// NOTE: The negative lookbehind prevents matches like "mail@lists", while | // NOTE: The negative lookbehind prevents matches like "mail@lists", while | ||||
// allowing constructs like "@tomo/@mroch". Since we now allow periods in | // allowing constructs like "@tomo/@mroch". Since we now allow periods in | ||||
// usernames, we can't resonably distinguish that "@company.com" isn't a | // usernames, we can't reasonably distinguish that "@company.com" isn't a | ||||
// username, so we'll incorrectly pick it up, but there's little to be done | // username, so we'll incorrectly pick it up, but there's little to be done | ||||
// about that. We forbid terminal periods so that we can correctly capture | // about that. We forbid terminal periods so that we can correctly capture | ||||
// "@joe" instead of "@joe." in "Hey, @joe.". | // "@joe" instead of "@joe." in "Hey, @joe.". | ||||
// | // | ||||
// We disallow "@@joe" because it creates a false positive in the common | // We disallow "@@joe" because it creates a false positive in the common | ||||
// construction "l@@k", made popular by eBay. | // construction "l@@k", made popular by eBay. | ||||
const REGEX = '/(?<!\w|@)@([a-zA-Z0-9._-]*[a-zA-Z0-9_-])/'; | const REGEX = '/(?<!\w|@)@([a-zA-Z0-9._-]*[a-zA-Z0-9_-])/'; | ||||
▲ Show 20 Lines • Show All 171 Lines • Show Last 20 Lines |