Skip to content

Commit

Permalink
Bugfix solution #537 for cached template
Browse files Browse the repository at this point in the history
  • Loading branch information
the-djmaze committed Feb 22, 2023
1 parent c83cf64 commit ade75b4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions snappymail/v/0.0.0/app/libraries/RainLoop/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,8 @@ private static function RunResult() : bool
if ($sResult) {
$sResult .= '<!--cached-->';
} else {
$SameSite = \strtolower($oConfig->Get('security', 'cookie_samesite', 'Strict'));
$Secure = (isset($_SERVER['HTTPS']) || 'none' == $SameSite) ? ';secure' : '';
$aTemplateParameters['{{BaseAppBootCss}}'] = \file_get_contents(APP_VERSION_ROOT_PATH.'static/css/boot'.$sAppCssMin.'.css');
$aTemplateParameters['{{BaseAppBootScript}}'] = \str_replace(
'samesite=strict',
"samesite={$SameSite}{$Secure}",
\file_get_contents(APP_VERSION_ROOT_PATH.'static/js'.($sAppJsMin ? '/min' : '').'/boot'.$sAppJsMin.'.js')
);
$aTemplateParameters['{{BaseAppBootScript}}'] = \file_get_contents(APP_VERSION_ROOT_PATH.'static/js'.($sAppJsMin ? '/min' : '').'/boot'.$sAppJsMin.'.js');
$aTemplateParameters['{{BaseAppMainCssLink}}'] = Utils::WebStaticPath('css/'.($bAdmin ? 'admin' : 'app').$sAppCssMin.'.css');
$aTemplateParameters['{{BaseAppThemeCss}}'] = \preg_replace('/\\s*([:;{},]+)\\s*/s', '$1', $oActions->compileCss($sThemeName, $bAdmin));
$aTemplateParameters['{{BaseLanguage}}'] = $oActions->compileLanguage($sLanguage, $bAdmin);
Expand All @@ -204,6 +198,10 @@ private static function RunResult() : bool
}
}

$SameSite = \strtolower($oConfig->Get('security', 'cookie_samesite', 'Strict'));
$Secure = (isset($_SERVER['HTTPS']) || 'none' == $SameSite) ? ';secure' : '';
$sResult = \str_replace('samesite=strict', "samesite={$SameSite}{$Secure}", $sResult);

$sScriptNonce = \SnappyMail\UUID::generate();
static::setCSP($sScriptNonce);
$sResult = \str_replace('nonce=""', 'nonce="'.$sScriptNonce.'"', $sResult);
Expand Down

0 comments on commit ade75b4

Please sign in to comment.