diff --git a/src/infrastructure/markup/rule/PhabricatorObjectRemarkupRule.php b/src/infrastructure/markup/rule/PhabricatorObjectRemarkupRule.php --- a/src/infrastructure/markup/rule/PhabricatorObjectRemarkupRule.php +++ b/src/infrastructure/markup/rule/PhabricatorObjectRemarkupRule.php @@ -166,7 +166,10 @@ $prefix = preg_quote($prefix); $id = $this->getObjectIDPattern(); - return '(\B{'.$prefix.'('.$id.')([,\s](?:[^}\\\\]|\\\\.)*)?}\B)u'; + $base_uri = PhabricatorEnv::getEnvConfig('phabricator.base-uri'); + $base_uri = new PhutilURI($base_uri); + + return '(\B{'.'(?:'.preg_quote($base_uri).'/)?'.$prefix.'('.$id.')([,\s](?:[^}\\\\]|\\\\.)*)?}\B)u'; } private function getObjectReferencePattern() { @@ -175,6 +178,8 @@ $id = $this->getObjectIDPattern(); + $base_uri = new PhutilURI(PhabricatorEnv::getEnvConfig('phabricator.base-uri')); + // If the prefix starts with a word character (like "D"), we want to // require a word boundary so that we don't match "XD1" as "D1". If the // prefix does not start with a word character, we want to require no word @@ -192,7 +197,7 @@ // 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.'(?:'.preg_quote($base_uri).'/)?'.$prefix.'('.$id.')(?:#([-\w\d]+))?(?!\w))u'; } @@ -243,7 +248,7 @@ return $results; } - public function markupObjectEmbed($matches) { + public function markupObjectEmbed(array $matches) { if (!$this->isFlatText($matches[0])) { return $matches[0]; } @@ -256,7 +261,7 @@ )); } - public function markupObjectReference($matches) { + public function markupObjectReference(array $matches) { if (!$this->isFlatText($matches[0])) { return $matches[0]; }