Skip to content

Commit c9e7625

Browse files
committed
add unique defaultUbiquity
1 parent 186256e commit c9e7625

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Ubiquity/security/csp/ContentSecurityManager.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public static function getNonce(string $name): string {
6262
public static function getHash(string $name, string $code, string $algo = 'sha256'): string {
6363
$code = \preg_replace('/\r\n/', '\n', $code);
6464
$hash = \base64_encode(\hash($algo, $code, true));
65-
if (isset(self::$onGenerate) && ! URequest::isAjax()) {
65+
$hash="$algo-$hash";
66+
if (isset(self::$onGenerate) && !URequest::isAjax()) {
6667
$onG = self::$onGenerate;
6768
$onG($name, $hash, $algo);
6869
}
@@ -114,7 +115,7 @@ public static function clearCsp(): void {
114115
* @return ContentSecurity
115116
*/
116117
public static function defaultUbiquity(?bool $reportOnly = null): ContentSecurity {
117-
return self::$csp[] = ContentSecurity::defaultUbiquity()->reportOnly($reportOnly);
118+
return self::$csp['defaultUbiquity'] ??= ContentSecurity::defaultUbiquity()->reportOnly($reportOnly);
118119
}
119120

120121
/**
@@ -125,7 +126,7 @@ public static function defaultUbiquity(?bool $reportOnly = null): ContentSecurit
125126
* @return ContentSecurity
126127
*/
127128
public static function defaultUbiquityDebug(?bool $reportOnly = null, string $livereloadServer = '127.0.0.1:35729'): ContentSecurity {
128-
return self::$csp[] = ContentSecurity::defaultUbiquityDebug($livereloadServer)->reportOnly($reportOnly);
129+
return self::$csp['defaultUbiquity'] ??= ContentSecurity::defaultUbiquityDebug($livereloadServer)->reportOnly($reportOnly);
129130
}
130131

131132
/**

0 commit comments

Comments
 (0)