Skip to content

Commit 19380aa

Browse files
committed
Created a method to clear nonce placeholders.
1 parent 1b41358 commit 19380aa

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

system/HTTP/ContentSecurityPolicy.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,4 +1052,9 @@ public function clearDirective(string $directive): void
10521052

10531053
$this->{$this->directives[$directive]} = [];
10541054
}
1055+
1056+
public function clearNoncePlaceholders(string $text): string
1057+
{
1058+
return str_replace([$this->styleNonceTag, $this->scriptNonceTag], '', $text);
1059+
}
10551060
}

system/HTTP/ResponseTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ public function send()
370370
if ($this->CSP->enabled()) {
371371
$this->CSP->finalize($this);
372372
} else {
373-
$this->body = str_replace(['{csp-style-nonce}', '{csp-script-nonce}'], '', $this->body ?? '');
373+
$this->body = $this->CSP->clearNoncePlaceholders($this->body);
374374
}
375375

376376
$this->sendHeaders();

0 commit comments

Comments
 (0)