diff --git a/src/markup/engine/remarkup/markuprule/PhutilRemarkupHyperlinkRule.php b/src/markup/engine/remarkup/markuprule/PhutilRemarkupHyperlinkRule.php --- a/src/markup/engine/remarkup/markuprule/PhutilRemarkupHyperlinkRule.php +++ b/src/markup/engine/remarkup/markuprule/PhutilRemarkupHyperlinkRule.php @@ -17,7 +17,7 @@ $text); // Anything else we match "ungreedily", which means we'll look for - // stuff that's probably puncutation or otherwise not part of the URL and + // stuff that's probably punctuation or otherwise not part of the URL and // not link it. This lets someone write "QuicK! Go to // http://www.example.com/!". We also apply some paren balancing rules. @@ -32,17 +32,26 @@ } protected function markupHyperlink($matches) { + $base_uri = new PhutilURI(PhabricatorEnv::getEnvConfig('phabricator.base-uri')); $protocols = $this->getEngine()->getConfig( 'uri.allowed-protocols', array()); - $protocol = id(new PhutilURI($matches[1]))->getProtocol(); - if (!idx($protocols, $protocol)) { + $uri = new PhutilURI($matches[1]); + + if (!idx($protocols, $uri->getProtocol())) { // If this URI doesn't use a whitelisted protocol, don't link it. This // is primarily intended to prevent javascript:// silliness. return $this->getEngine()->storeText($matches[1]); } + if ($uri->getDomain() == $base_uri->getDomain()) { + // Don't modify the text. This allows PhabricatorObjectRemarkupRule the + // opportunity to process the text. + return $matches[1]; + } + + return $this->storeRenderedHyperlink($matches[1]); }