diff --git a/src/applications/phurl/controller/PhabricatorPhurlURLViewController.php b/src/applications/phurl/controller/PhabricatorPhurlURLViewController.php index 4483b9bb77..1ddc2a8344 100644 --- a/src/applications/phurl/controller/PhabricatorPhurlURLViewController.php +++ b/src/applications/phurl/controller/PhabricatorPhurlURLViewController.php @@ -96,13 +96,33 @@ final class PhabricatorPhurlURLViewController $url, PhabricatorPolicyCapability::CAN_EDIT); - $actions->addAction( - id(new PhabricatorActionView()) - ->setName(pht('Edit')) - ->setIcon('fa-pencil') - ->setHref($this->getApplicationURI("url/edit/{$id}/")) - ->setDisabled(!$can_edit) - ->setWorkflow(!$can_edit)); + $allowed_protocols = PhabricatorEnv::getEnvConfig('uri.allowed-protocols'); + $uri = new PhutilURI($url->getLongURL()); + $url_protocol = $uri->getProtocol(); + + $can_access = false; + $redirect_uri = $url->getMonogram(); + + if (strlen($url_protocol)) { + $can_access = in_array($url_protocol, $allowed_protocols); + $redirect_uri = $uri; + } + + $actions + ->addAction( + id(new PhabricatorActionView()) + ->setName(pht('Edit')) + ->setIcon('fa-pencil') + ->setHref($this->getApplicationURI("url/edit/{$id}/")) + ->setDisabled(!$can_edit) + ->setWorkflow(!$can_edit)) + ->addAction( + id(new PhabricatorActionView()) + ->setName(pht('Visit URL')) + ->setIcon('fa-external-link') + ->setHref($redirect_uri) + ->setDisabled(!$can_edit || !$can_access) + ->setWorkflow(!$can_edit)); return $actions; }