diff --git a/system/HTTP/ContentSecurityPolicy.php b/system/HTTP/ContentSecurityPolicy.php index a6a2b26a71fc..4767face673e 100644 --- a/system/HTTP/ContentSecurityPolicy.php +++ b/system/HTTP/ContentSecurityPolicy.php @@ -303,7 +303,7 @@ public function enabled(): bool public function getStyleNonce(): string { if ($this->styleNonce === null) { - $this->styleNonce = bin2hex(random_bytes(12)); + $this->styleNonce = base64_encode(random_bytes(12)); $this->styleSrc[] = 'nonce-' . $this->styleNonce; } @@ -316,7 +316,7 @@ public function getStyleNonce(): string public function getScriptNonce(): string { if ($this->scriptNonce === null) { - $this->scriptNonce = bin2hex(random_bytes(12)); + $this->scriptNonce = base64_encode(random_bytes(12)); $this->scriptSrc[] = 'nonce-' . $this->scriptNonce; } diff --git a/tests/system/CommonFunctionsTest.php b/tests/system/CommonFunctionsTest.php index bc09ef6e9f57..d84378e01dc9 100644 --- a/tests/system/CommonFunctionsTest.php +++ b/tests/system/CommonFunctionsTest.php @@ -731,7 +731,7 @@ public function testDWithCSP(): void $cliDetection = Kint::$cli_detection; Kint::$cli_detection = false; - $this->expectOutputRegex('/