diff --git a/src/applications/project/remarkup/ProjectRemarkupRule.php b/src/applications/project/remarkup/ProjectRemarkupRule.php --- a/src/applications/project/remarkup/ProjectRemarkupRule.php +++ b/src/applications/project/remarkup/ProjectRemarkupRule.php @@ -20,17 +20,13 @@ } protected function getObjectIDPattern() { - // NOTE: This explicitly does not match strings which contain only - // digits, because digit strings like "#123" are used to reference tasks at - // Facebook and are somewhat conventional in general. - - // The latter half of this rule matches monograms with internal periods, - // like `#domain.com`, but does not match monograms with terminal periods, - // because they're probably just puncutation. + // NOTE: The latter half of this rule matches monograms with internal + // periods, like `#domain.com`, but does not match monograms with terminal + // periods, because they're probably just puncutation. // Broadly, this will not match every possible project monogram, and we - // accept some false negatives -- like `#1` or `#dot.` -- in order to avoid - // a bunch of false positives on general use of the `#` character. + // accept some false negatives -- like `#dot.` -- in order to avoid a bunch + // of false positives on general use of the `#` character. // In other contexts, the PhabricatorProjectProjectPHIDType pattern is // controlling and these names should parse correctly. @@ -38,17 +34,14 @@ // These characters may never appear anywhere in a hashtag. $never = '\s?!,:;{}#\\(\\)"\''; - // These characters may not appear at the beginning. - $never_first = '.\d'; - - // These characters may not appear at the end. - $never_last = '.'; + // These characters may not appear at the edge of the string. + $never_edge = '.'; return - '[^'.$never_first.$never.']+'. + '[^'.$never_edge.$never.']+'. '(?:'. '[^'.$never.']*'. - '[^'.$never_last.$never.']+'. + '[^'.$never_edge.$never.']+'. ')*'; } diff --git a/src/applications/project/remarkup/__tests__/ProjectRemarkupRuleTestCase.php b/src/applications/project/remarkup/__tests__/ProjectRemarkupRuleTestCase.php --- a/src/applications/project/remarkup/__tests__/ProjectRemarkupRuleTestCase.php +++ b/src/applications/project/remarkup/__tests__/ProjectRemarkupRuleTestCase.php @@ -33,7 +33,21 @@ ), '#123' => array( 'embed' => array(), - 'ref' => array(), + 'ref' => array( + array( + 'offset' => 1, + 'id' => '123', + ), + ), + ), + '#2x4' => array( + 'embed' => array(), + 'ref' => array( + array( + 'offset' => 1, + 'id' => '2x4', + ), + ), ), '#security#123' => array( 'embed' => array(),