Page MenuHomePhabricator

D12692.id30470.diff
No OneTemporary

D12692.id30470.diff

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() {
@@ -175,6 +184,9 @@
$id = $this->getObjectIDPattern();
+ $base_uri = PhabricatorEnv::getEnvConfig('phabricator.base-uri');
+ $base_uri = new PhutilURI($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
@@ -188,11 +200,14 @@
// The "(?<![#-])" prevents us from linking "#abcdef" or similar, and
// "ABC-T1" (see T5714).
-
+ //
// 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 +258,7 @@
return $results;
}
- public function markupObjectEmbed($matches) {
+ public function markupObjectEmbed(array $matches) {
if (!$this->isFlatText($matches[0])) {
return $matches[0];
}
@@ -256,7 +271,7 @@
));
}
- public function markupObjectReference($matches) {
+ public function markupObjectReference(array $matches) {
if (!$this->isFlatText($matches[0])) {
return $matches[0];
}

File Metadata

Mime Type
text/plain
Expires
Aug 1 2025, 11:39 PM (11 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8752870
Default Alt Text
D12692.id30470.diff (3 KB)

Event Timeline