Small cleanup

This commit is contained in:
djmaze 2021-08-10 14:50:47 +02:00
parent 8b10abe5ac
commit 4cb88b408c
2 changed files with 3 additions and 4 deletions

View file

@ -402,8 +402,7 @@ END;
public static function IsUtf8(string $sValue) : bool
{
return (bool) (\function_exists('mb_check_encoding') ?
\mb_check_encoding($sValue, 'UTF-8') : \preg_match('//u', $sValue));
return \mb_check_encoding($sValue, 'UTF-8');
}
public static function FormatFileSize(int $iSize, int $iRound = 0) : string

View file

@ -216,10 +216,10 @@ class Service
}
// Internet Explorer does not support 'nonce'
if (!\strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/') && !\strpos($_SERVER['HTTP_USER_AGENT'], 'Edge/1')) {
// Knockout.js requires unsafe-inline?
if ($sScriptNonce) {
$sContentSecurityPolicy = \preg_replace("/(script-src[^;]+)'unsafe-inline'/", "\$1'nonce-{$sScriptNonce}'", $sContentSecurityPolicy);
$sContentSecurityPolicy = \str_replace('script-src', "script-src 'nonce-{$sScriptNonce}'", $sContentSecurityPolicy);
}
// Knockout.js requires unsafe-inline?
$sContentSecurityPolicy = \preg_replace("/(script-src[^;]+)'unsafe-inline'/", '$1', $sContentSecurityPolicy);
// Knockout.js requires eval() for observable binding purposes
//$sContentSecurityPolicy = \preg_replace("/(script-src[^;]+)'unsafe-eval'/", '$1', $sContentSecurityPolicy);