diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index 608159971..f9e3a12a7 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -496,18 +496,20 @@ class ActionController extends Zend_Controller_Action $resp->setReloadCss(true); } - if ($this->view->title) { - if (preg_match('~[\r\n]~', $this->view->title)) { - // TODO: Innocent exception and error log for hack attempts - throw new IcingaException('No way, guy'); + if ($resp->getHeader('X-Icinga-Title') === null) { + if ($this->view->title) { + if (preg_match('~[\r\n]~', $this->view->title)) { + // TODO: Innocent exception and error log for hack attempts + throw new IcingaException('No way, guy'); + } + $resp->setHeader( + 'X-Icinga-Title', + rawurlencode($this->view->title . ' :: ' . $this->view->defaultTitle), + true + ); + } else { + $resp->setHeader('X-Icinga-Title', rawurlencode($this->view->defaultTitle), true); } - $resp->setHeader( - 'X-Icinga-Title', - rawurlencode($this->view->title . ' :: ' . $this->view->defaultTitle), - true - ); - } else { - $resp->setHeader('X-Icinga-Title', rawurlencode($this->view->defaultTitle), true); } $layout = $this->_helper->layout(); diff --git a/public/js/icinga/behavior/modal.js b/public/js/icinga/behavior/modal.js index 90869389a..a575e01ea 100644 --- a/public/js/icinga/behavior/modal.js +++ b/public/js/icinga/behavior/modal.js @@ -109,6 +109,11 @@ req.addToHistory = false; req.$redirectTarget = $modal.data('redirectTarget'); req.done(function (data, textStatus, req) { + var title = req.getResponseHeader('X-Icinga-Title'); + if (!! title) { + _this.setTitle($modal, decodeURIComponent(title).replace(/\s::\s.*/, '')); + } + if (req.getResponseHeader('X-Icinga-Redirect')) { _this.hide($modal); }