@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3abstract class PhabricatorRemarkupHyperlinkEngineExtension
4 extends PhutilRemarkupHyperlinkEngineExtension {
5
6 /**
7 * @param array<PhutilRemarkupHyperlinkRef> $hyperlinks
8 */
9 final protected function getSelfLinks(array $hyperlinks) {
10 assert_instances_of($hyperlinks, PhutilRemarkupHyperlinkRef::class);
11
12 $allowed_protocols = array(
13 'http' => true,
14 'https' => true,
15 );
16
17 $results = array();
18 foreach ($hyperlinks as $link) {
19 $uri = $link->getURI();
20
21 if (!PhabricatorEnv::isSelfURI($uri)) {
22 continue;
23 }
24
25 $protocol = id(new PhutilURI($uri))->getProtocol();
26 if (!isset($allowed_protocols[$protocol])) {
27 continue;
28 }
29
30 $results[] = $link;
31 }
32
33 return $results;
34 }
35}