Page MenuHomePhabricator

D15497.id37356.diff
No OneTemporary

D15497.id37356.diff

diff --git a/src/applications/phurl/remarkup/PhabricatorPhurlLinkRemarkupRule.php b/src/applications/phurl/remarkup/PhabricatorPhurlLinkRemarkupRule.php
--- a/src/applications/phurl/remarkup/PhabricatorPhurlLinkRemarkupRule.php
+++ b/src/applications/phurl/remarkup/PhabricatorPhurlLinkRemarkupRule.php
@@ -18,7 +18,9 @@
public function markupLink(array $matches) {
$engine = $this->getEngine();
$viewer = $engine->getConfig('viewer');
+
$text_mode = $engine->isTextMode();
+ $html_mode = $engine->isHTMLMailMode();
if (!$this->isFlatText($matches[0])) {
return $matches[0];
@@ -28,46 +30,45 @@
$monogram = null;
$is_monogram = '/^U(?P<id>[1-9]\d*)/';
+ $query = id(new PhabricatorPhurlURLQuery())
+ ->setViewer($viewer);
+
if (preg_match($is_monogram, $ref, $monogram)) {
- $phurls = id(new PhabricatorPhurlURLQuery())
- ->setViewer($viewer)
- ->withIDs(array($monogram[1]))
- ->execute();
+ $query->withIDs(array($monogram[1]));
} else if (ctype_digit($ref)) {
- $phurls = id(new PhabricatorPhurlURLQuery())
- ->setViewer($viewer)
- ->withIDs(array($ref))
- ->execute();
+ $query->withIDs(array($ref));
} else {
- $phurls = id(new PhabricatorPhurlURLQuery())
- ->setViewer($viewer)
- ->withAliases(array($ref))
- ->execute();
+ $query->withAliases(array($ref));
+ }
+
+ $phurl = $query->executeOne();
+ if (!$phurl) {
+ return $matches[0];
}
- $phurl = head($phurls);
+ $uri = $phurl->getRedirectURI();
+ $name = $phurl->getDisplayName();
- if ($phurl) {
- if ($text_mode) {
- return $phurl->getDisplayName().
- ' <'.
- $phurl->getRedirectURI().
- '>';
- }
+ if ($text_mode || $html_mode) {
+ $uri = PhabricatorEnv::getProductionURI($uri);
+ }
+ if ($text_mode) {
+ return pht(
+ '%s <%s>',
+ $name,
+ $uri);
+ } else {
$link = phutil_tag(
'a',
array(
- 'href' => $phurl->getRedirectURI(),
+ 'href' => $uri,
'target' => '_blank',
),
- $phurl->getDisplayName());
-
- return $this->getEngine()->storeText($link);
- } else {
- return $matches[0];
+ $name);
}
- }
+ return $this->getEngine()->storeText($link);
+ }
}

File Metadata

Mime Type
text/plain
Expires
Mon, Apr 14, 5:25 PM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7225365
Default Alt Text
D15497.id37356.diff (2 KB)

Event Timeline