@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
3final class PhabricatorDatasourceURIEngineExtension
4 extends PhabricatorDatasourceEngineExtension {
5
6 public function newQuickSearchDatasources() {
7 return array();
8 }
9
10 public function newJumpURI($query) {
11 // If you search for a URI on the local install, just redirect to that
12 // URI as though you had pasted it into the URI bar.
13 // Skip things that are really not full URLs, like "asdasd".
14 // Note that the backend of "isSelfURI" is faster with a PhutilURI.
15 $uri = new PhutilURI($query);
16 if ($uri->getDomain() === '' || !PhabricatorEnv::isSelfURI($uri)) {
17 return null;
18 }
19
20 // Strip off the absolute part of the URI. If we don't, the URI redirect
21 // validator will get upset that we're performing an unmarked external
22 // redirect.
23
24 // The correct host and protocol may also differ from the host and
25 // protocol used in the search: for example, if you search for "http://"
26 // we want to redirect to "https://" if an install is HTTPS, and
27 // the "isSelfURI()" check includes alternate domains in addition to the
28 // canonical domain.
29 $uri = $uri
30 ->setDomain(null)
31 ->setProtocol(null)
32 ->setPort(null);
33
34 $uri = phutil_string_cast($uri);
35
36 // See T13412. If the URI was in the form "http://dev.example.com" with
37 // no trailing slash, there may be no path. Redirecting to the empty
38 // string is considered an error by safety checks during redirection,
39 // so treat this like the user entered the URI with a trailing slash.
40 if (!strlen($uri)) {
41 $uri = '/';
42 }
43
44 return $uri;
45 }
46}