Merge pull request #3830 from Icinga/fix/object-actions-dont-handle-external-paths-properly-3829
Fix object actions dont handle external paths properly
This commit is contained in:
commit
245f392a9d
|
@ -191,11 +191,11 @@ class Url
|
|||
$urlPath = $urlParts['path'];
|
||||
if ($urlPath && $urlPath[0] === '/') {
|
||||
if ($urlObject->isExternal() || isset($urlParts['user'])) {
|
||||
$urlPath = substr($urlPath, 1);
|
||||
$urlPath = ltrim($urlPath, '/');
|
||||
} else {
|
||||
$requestBaseUrl = $request->getBaseUrl();
|
||||
if ($requestBaseUrl && $requestBaseUrl !== '/' && strpos($urlPath, $requestBaseUrl) === 0) {
|
||||
$urlPath = substr($urlPath, strlen($requestBaseUrl) + 1);
|
||||
$urlPath = ltrim(substr($urlPath, strlen($requestBaseUrl)), '/');
|
||||
$urlObject->setBasePath($requestBaseUrl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ use Icinga\Data\Filter\Filter;
|
|||
use Icinga\Web\Navigation\NavigationItem;
|
||||
use Icinga\Module\Monitoring\Object\Macro;
|
||||
use Icinga\Module\Monitoring\Object\MonitoredObject;
|
||||
use Icinga\Web\Url;
|
||||
|
||||
/**
|
||||
* Action for monitored objects
|
||||
|
@ -34,6 +35,13 @@ class Action extends NavigationItem
|
|||
*/
|
||||
protected $filter;
|
||||
|
||||
/**
|
||||
* This action's raw url attribute
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $rawUrl;
|
||||
|
||||
/**
|
||||
* Set this action's object
|
||||
*
|
||||
|
@ -80,14 +88,22 @@ class Action extends NavigationItem
|
|||
return $this->filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
if (is_string($url)) {
|
||||
$this->rawUrl = $url;
|
||||
} else {
|
||||
parent::setUrl($url);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
{
|
||||
$url = parent::getUrl();
|
||||
if (! $this->resolved && $url !== null) {
|
||||
$this->setUrl(Macro::resolveMacros($url->getAbsoluteUrl(), $this->getObject()));
|
||||
if (! $this->resolved && $url === null) {
|
||||
$this->setUrl(Url::fromPath(Macro::resolveMacros($this->rawUrl, $this->getObject())));
|
||||
$this->resolved = true;
|
||||
return parent::getUrl();
|
||||
} else {
|
||||
|
@ -95,9 +111,6 @@ class Action extends NavigationItem
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRender()
|
||||
{
|
||||
if ($this->render === null) {
|
||||
|
|
Loading…
Reference in New Issue