Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15381417
D12692.id30476.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12692.id30476.diff
View Options
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 "(?<![#-])" 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.
+ '([a-zA-Z]+://\w+\.\w+/)?'.
+ $prefix.'('.$id.')'.
+ '(?:#([-\w\d]+))?(?!\w))u';
}
@@ -229,11 +241,11 @@
$formatted = array();
foreach ($matches as $match) {
$format = array(
- 'offset' => $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);
+
+ 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],
));
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 15, 7:33 AM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7686686
Default Alt Text
D12692.id30476.diff (3 KB)
Attached To
Mode
D12692: Allow full URIs to be rendered as object references
Attached
Detach File
Event Timeline
Log In to Comment