Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/meta/engineextension/PhabricatorDatasourceURIEngineExtension.php
12256 views
1
<?php
2
3
final 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
if (PhabricatorEnv::isSelfURI($query)) {
14
// Strip off the absolute part of the URI. If we don't, the URI redirect
15
// validator will get upset that we're performing an unmarked external
16
// redirect.
17
18
// The correct host and protocol may also differ from the host and
19
// protocol used in the search: for example, if you search for "http://"
20
// we want to redirect to "https://" if an install is HTTPS, and
21
// the "isSelfURI()" check includes alternate domains in addition to the
22
// canonical domain.
23
24
$uri = id(new PhutilURI($query))
25
->setDomain(null)
26
->setProtocol(null)
27
->setPort(null);
28
29
$uri = phutil_string_cast($uri);
30
31
// See T13412. If the URI was in the form "http://dev.example.com" with
32
// no trailing slash, there may be no path. Redirecting to the empty
33
// string is considered an error by safety checks during redirection,
34
// so treat this like the user entered the URI with a trailing slash.
35
if (!strlen($uri)) {
36
$uri = '/';
37
}
38
39
return $uri;
40
}
41
42
return null;
43
}
44
}
45
46