From 4cff1feb8fe2231df6568e9d1d711540984c80fe Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Wed, 9 Mar 2022 21:39:17 +0100 Subject: [PATCH] ActionController: Don't override `X-Icinga-Title` when it's already set --- .../Web/Controller/ActionController.php | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) 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();