diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Service.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Service.php index d9519f589..d32bcd1a4 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Service.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Service.php @@ -89,7 +89,6 @@ class Service private function localHandle() : self { $sResult = ''; - $bCached = false; $sQuery = $this->oActions->ParseQueryAuthString(); @@ -145,7 +144,7 @@ class Service if ($bIndex) { - header('Content-Type: text/html; charset=utf-8'); + \header('Content-Type: text/html; charset=utf-8'); $this->oHttp->ServerNoCache(); if (!\is_dir(APP_DATA_FOLDER_PATH) || !\is_writable(APP_DATA_FOLDER_PATH)) @@ -170,8 +169,9 @@ class Service $sResult = $this->oActions->Cacher()->Get($sCacheFileName); } - if (0 === \strlen($sResult)) - { + if ($sResult) { + $sResult .= ''; + } else { $aTemplateParameters['{{BaseAppThemeCss}}'] = $this->oActions->compileCss($this->oActions->GetTheme($bAdmin), $bAdmin); $aTemplateParameters['{{BaseLanguage}}'] = $this->oActions->compileLanguage($sLanguage, $bAdmin); $aTemplateParameters['{{BaseTemplates}}'] = $this->oServiceActions->compileTemplates($bAdmin, false); @@ -182,20 +182,8 @@ class Service $this->oActions->Cacher()->Set($sCacheFileName, $sResult); } } - else - { - $bCached = true; - } - - $sResult .= ''; } - else if (!headers_sent()) + else if (!\headers_sent()) { \header('X-XSS-Protection: 1; mode=block'); } diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php b/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php index 3de4a9d91..e04c772ea 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php @@ -576,18 +576,15 @@ class ServiceActions $sResult = $this->Cacher()->Get($sCacheFileName); } - if (0 === \strlen($sResult)) + if (!$sResult) { try { $sResult = $this->oActions->compileCss($sTheme, $bAdmin); - if ($bCacheEnabled) + if ($bCacheEnabled && $sCacheFileName) { - if (0 < \strlen($sCacheFileName)) - { - $this->Cacher()->Set($sCacheFileName, $sResult); - } + $this->Cacher()->Set($sCacheFileName, $sResult); } } catch (\Throwable $oException) diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Utils.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Utils.php index cd1e87d53..627ad7295 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Utils.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Utils.php @@ -161,13 +161,11 @@ class Utils public static function ClearHtmlOutput(string $sHtml) : string { // return $sHtml; - return \trim(\str_replace('> <', '><', - \str_replace('" />', '"/>', - \preg_replace('/[\s]+ /i', ' ', - \preg_replace('/ [\s]+/i', ' ', - \preg_replace('/[\r\n\t]+/', ' ', - $sHtml - )))))); + return \preg_replace( + ['@"\\s*/>@', '/\\s* /i', '/ \\s*/i', '/[\\r\\n\\t]+/', '/>\\s+', ' ', ' ', ' ', '><'], + \trim($sHtml) + ); } public static function CompileTemplates(array &$aList, string $sDirName, string $sNameSuffix = '')