From 94cd3769b0e2611479a0470f1550815b2be9c88e Mon Sep 17 00:00:00 2001 From: diosmosis Date: Thu, 15 Aug 2019 20:02:02 -0700 Subject: [PATCH 1/2] Admin controllers do not call setGeneralVariablesView, so we have to set the property another way. --- core/Plugin/Controller.php | 5 ++++- core/Plugin/ControllerAdmin.php | 1 - plugins/Morpheus/templates/_jsGlobalVariables.twig | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/Plugin/Controller.php b/core/Plugin/Controller.php index 39d8f837b87..9b4f8dbf2c8 100644 --- a/core/Plugin/Controller.php +++ b/core/Plugin/Controller.php @@ -313,6 +313,10 @@ protected function renderTemplateAs($template, array $variables = array(), $view $view->$key = $value; } + if (isset($view->siteName)) { + $view->siteNameDecoded = Common::unsanitizeInputValue($view->siteName); + } + return $view->render(); } @@ -615,7 +619,6 @@ protected function setGeneralVariablesViewAs($view, $viewType) $this->setPeriodVariablesView($view); $view->siteName = $this->site->getName(); - $view->siteNameDecoded = Common::unsanitizeInputValue($view->siteName); $view->siteMainUrl = $this->site->getMainUrl(); $siteTimezone = $this->site->getTimezone(); diff --git a/core/Plugin/ControllerAdmin.php b/core/Plugin/ControllerAdmin.php index 90189d55561..82b5e2e4cfa 100644 --- a/core/Plugin/ControllerAdmin.php +++ b/core/Plugin/ControllerAdmin.php @@ -128,7 +128,6 @@ private static function notifyAnyInvalidPlugin() protected function setBasicVariablesViewAs($view, $viewType = 'admin') { $this->setBasicVariablesNoneAdminView($view); - if ($viewType == 'admin') { self::setBasicVariablesAdminView($view); } diff --git a/plugins/Morpheus/templates/_jsGlobalVariables.twig b/plugins/Morpheus/templates/_jsGlobalVariables.twig index 2708c1679ae..fb76d79fd0e 100644 --- a/plugins/Morpheus/templates/_jsGlobalVariables.twig +++ b/plugins/Morpheus/templates/_jsGlobalVariables.twig @@ -23,7 +23,9 @@ {% if siteName is defined %} // NOTE: siteName is currently considered deprecated, use piwik.currentSiteName instead, which will not contain HTML entities piwik.siteName = "{{ siteName|e('js') }}"; + {% if currentSiteName is defined %} // just to be safe piwik.currentSiteName = {{ siteNameDecoded|json_encode|raw }};{% endif %} + {% endif %} {% if siteMainUrl is defined %}piwik.siteMainUrl = "{{ siteMainUrl|e('js') }}";{% endif %} From 41831e9126fbc6b9f1977dc085c68580ecc618f8 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Thu, 15 Aug 2019 21:10:57 -0700 Subject: [PATCH 2/2] fix typo --- plugins/Morpheus/templates/_jsGlobalVariables.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Morpheus/templates/_jsGlobalVariables.twig b/plugins/Morpheus/templates/_jsGlobalVariables.twig index fb76d79fd0e..36c03f0eb2f 100644 --- a/plugins/Morpheus/templates/_jsGlobalVariables.twig +++ b/plugins/Morpheus/templates/_jsGlobalVariables.twig @@ -23,7 +23,7 @@ {% if siteName is defined %} // NOTE: siteName is currently considered deprecated, use piwik.currentSiteName instead, which will not contain HTML entities piwik.siteName = "{{ siteName|e('js') }}"; - {% if currentSiteName is defined %} // just to be safe + {% if siteNameDecoded is defined %} // just to be safe piwik.currentSiteName = {{ siteNameDecoded|json_encode|raw }};{% endif %} {% endif %}