1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Fix regexp issue with Diffusion remarkup rule

Summary: My `\w` shenanigans don't work with Diffusion, which has no explicit prefix.

Test Plan: Typed `rXnnn` and got the whole thing properly marked up.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D5984
This commit is contained in:
epriestley 2013-05-20 13:27:03 -07:00
parent df50e380ca
commit cf092781ae
2 changed files with 10 additions and 1 deletions

View file

@ -7,6 +7,10 @@ final class DiffusionRemarkupRule
return '';
}
protected function getObjectNamePrefixBeginsWithWordCharacter() {
return true;
}
protected function getObjectIDPattern() {
$min_unqualified = PhabricatorRepository::MINIMUM_UNQUALIFIED_HASH;
$min_qualified = PhabricatorRepository::MINIMUM_QUALIFIED_HASH;

View file

@ -11,6 +11,11 @@ abstract class PhabricatorRemarkupRuleObject
abstract protected function getObjectNamePrefix();
abstract protected function loadObjects(array $ids);
protected function getObjectNamePrefixBeginsWithWordCharacter() {
$prefix = $this->getObjectNamePrefix();
return preg_match('/^\w/', $prefix);
}
protected function getObjectIDPattern() {
return '[1-9]\d*';
}
@ -104,7 +109,7 @@ abstract class PhabricatorRemarkupRuleObject
// prefix does not start with a word character, we want to require no word
// boundary for the same reasons. Test if the prefix starts with a word
// character.
if (preg_match('/^\w/', $prefix)) {
if ($this->getObjectNamePrefixBeginsWithWordCharacter()) {
$boundary = '\\b';
} else {
$boundary = '\\B';