Skip to content

Commit b6c7bf5

Browse files
committed
Add getter method and change helper methods according to new behaviour
1 parent 65b5bff commit b6c7bf5

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

system/Common.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ function csp_style_nonce(): string
335335
{
336336
$csp = service('csp');
337337

338-
if (! $csp->enabled()) {
338+
if (! $csp->styleNonceEnabled()) {
339339
return '';
340340
}
341341

@@ -351,7 +351,7 @@ function csp_script_nonce(): string
351351
{
352352
$csp = service('csp');
353353

354-
if (! $csp->enabled()) {
354+
if (! $csp->scriptNonceEnabled()) {
355355
return '';
356356
}
357357

system/HTTP/ContentSecurityPolicy.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,22 @@ public function enabled(): bool
406406
return $this->CSPEnabled;
407407
}
408408

409+
/**
410+
* Whether adding nonce in style-* directives is enabled or not.
411+
*/
412+
public function styleNonceEnabled(): bool
413+
{
414+
return $this->enabled() && $this->enableStyleNonce;
415+
}
416+
417+
/**
418+
* Whether adding nonce in script-* directives is enabled or not.
419+
*/
420+
public function scriptNonceEnabled(): bool
421+
{
422+
return $this->enabled() && $this->enableScriptNonce;
423+
}
424+
409425
/**
410426
* Get the nonce for the style tag.
411427
*/

0 commit comments

Comments
 (0)