forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhabricatorHelpEditorProtocolController.php
52 lines (42 loc) · 1.45 KB
/
PhabricatorHelpEditorProtocolController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
final class PhabricatorHelpEditorProtocolController
extends PhabricatorHelpController {
public function shouldAllowPublic() {
return true;
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$dialog = id(new AphrontDialogView())
->setUser($viewer)
->setMethod('GET')
->setSubmitURI('/settings/panel/display/')
->setTitle(pht('Unsupported Editor Protocol'))
->appendParagraph(
pht(
'Your configured editor URI uses an unsupported protocol. Change '.
'your settings to use a supported protocol, or ask your '.
'administrator to add support for the chosen protocol by '.
'configuring: %s',
phutil_tag('tt', array(), 'uri.allowed-editor-protocols')))
->addSubmitButton(pht('Change Settings'))
->addCancelButton('/');
return id(new AphrontDialogResponse())
->setDialog($dialog);
}
public static function hasAllowedProtocol($uri) {
$uri = new PhutilURI($uri);
$editor_protocol = $uri->getProtocol();
if (!$editor_protocol) {
// The URI must have a protocol.
return false;
}
$allowed_key = 'uri.allowed-editor-protocols';
$allowed_protocols = PhabricatorEnv::getEnvConfig($allowed_key);
if (empty($allowed_protocols[$editor_protocol])) {
// The protocol must be on the allowed protocol whitelist.
return false;
}
return true;
}
}