Skip to content

Commit 78ba1b0

Browse files
committed
fix: Allow nonce in csp header also if no other reasons are given
Signed-off-by: Julius Härtl <[email protected]>
1 parent 02d6d3f commit 78ba1b0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/public/AppFramework/Http/EmptyContentSecurityPolicy.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
* @since 9.0.0
3838
*/
3939
class EmptyContentSecurityPolicy {
40-
/** @var string JS nonce to be used */
41-
protected $jsNonce = null;
40+
/** @var ?string JS nonce to be used */
41+
protected ?string $jsNonce = null;
4242
/** @var bool Whether strict-dynamic should be used */
4343
protected $strictDynamicAllowed = null;
4444
/** @var bool Whether strict-dynamic should be used on script-src-elem */
@@ -460,7 +460,7 @@ public function buildPolicy() {
460460
$policy .= "base-uri 'none';";
461461
$policy .= "manifest-src 'self';";
462462

463-
if (!empty($this->allowedScriptDomains) || $this->evalScriptAllowed || $this->evalWasmAllowed) {
463+
if (!empty($this->allowedScriptDomains) || $this->evalScriptAllowed || $this->evalWasmAllowed || is_string($this->jsNonce)) {
464464
$policy .= 'script-src ';
465465
$scriptSrc = '';
466466
if (is_string($this->jsNonce)) {

0 commit comments

Comments
 (0)