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 @@ -9,7 +9,7 @@ abstract protected function loadObjects(array $ids); public function getPriority() { - return 450.0; + return 350.0; } protected function getObjectNamePrefixBeginsWithWordCharacter() { @@ -44,11 +44,12 @@ return $handle->getURI(); } - protected function renderObjectRefForAnyMedia ( - $object, - $handle, - $anchor, - $id) { + protected function renderObjectRefForAnyMedia( + $object, + $handle, + $anchor, + $id) { + $href = $this->getObjectHref($object, $handle, $id); $text = $this->getObjectNamePrefix().$id; @@ -106,7 +107,7 @@ $status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED; $attr = array( 'phid' => $handle->getPHID(), - 'closed' => ($handle->getStatus() == $status_closed), + 'closed' => ($handle->getStatus() == $status_closed), ); return $this->renderHovertag($name, $href, $attr); @@ -166,7 +167,15 @@ $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() { @@ -188,11 +197,14 @@ // The "(? $match[1][1], - 'id' => $match[1][0], + 'offset' => $match[2][1], + 'id' => $match[2][0], ); - if (isset($match[2][0])) { - $format['tail'] = $match[2][0]; + if (isset($match[3][0])) { + $format['tail'] = $match[3][0]; } $formatted[] = $format; } @@ -243,7 +255,7 @@ return $results; } - public function markupObjectEmbed($matches) { + public function markupObjectEmbed(array $matches) { if (!$this->isFlatText($matches[0])) { return $matches[0]; } @@ -256,15 +268,26 @@ )); } - public function markupObjectReference($matches) { + public function markupObjectReference(array $matches) { if (!$this->isFlatText($matches[0])) { return $matches[0]; } + if ($matches[1]) { + $uri = new PhutilURI($matches[1]); + + $base_uri = PhabricatorEnv::getEnvConfig('phabricator.base-uri'); + $base_uri = new PhutilURI($base_uri); +trigger_error($uri->getDomain()); + if (strtolower($uri->getDomain()) != strtolower($base_uri->getDomain())) { + return $matches[0]; + } + } + return $this->markupObject(array( 'type' => 'ref', - 'id' => $matches[1], - 'anchor' => idx($matches, 2), + 'id' => $matches[2], + 'anchor' => idx($matches, 3), 'original' => $matches[0], )); }