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() { @@ -53,7 +53,7 @@ return $uri; } - protected function renderObjectRefForAnyMedia ( + protected function renderObjectRefForAnyMedia( $object, PhabricatorObjectHandle $handle, $anchor, @@ -129,7 +129,7 @@ $status_closed = PhabricatorObjectHandle::STATUS_CLOSED; $attr = array( 'phid' => $handle->getPHID(), - 'closed' => ($handle->getStatus() == $status_closed), + 'closed' => ($handle->getStatus() == $status_closed), ); return $this->renderHovertag($name, $href, $attr); @@ -189,7 +189,12 @@ $prefix = preg_quote($prefix); $id = $this->getObjectIDPattern(); - return '(\B{'.$prefix.'('.$id.')([,\s](?:[^}\\\\]|\\\\.)*)?}\B)u'; + return + '(\B{'. + '([a-zA-Z]+://\w+\.\w+/)?'. + $prefix.'('.$id.')'. + '([,\s](?:[^}\\\\]|\\\\.)*)?'. + '}\B)u'; } private function getObjectReferencePattern() { @@ -211,11 +216,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; } @@ -271,10 +279,21 @@ return $matches[0]; } + if ($matches[1]) { + $uri = new PhutilURI($matches[1]); + + $base_uri = PhabricatorEnv::getEnvConfig('phabricator.base-uri'); + $base_uri = new PhutilURI($base_uri); + + if (strtolower($uri->getDomain()) != strtolower($base_uri->getDomain())) { + return $matches[0]; + } + } + return $this->markupObject(array( 'type' => 'embed', - 'id' => $matches[1], - 'options' => idx($matches, 2), + 'id' => $matches[2], + 'options' => idx($matches, 3), 'original' => $matches[0], )); } @@ -284,10 +303,21 @@ return $matches[0]; } + if ($matches[1]) { + $uri = new PhutilURI($matches[1]); + + $base_uri = PhabricatorEnv::getEnvConfig('phabricator.base-uri'); + $base_uri = new PhutilURI($base_uri); + + 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], )); }