Skip to content

Commit 61d4cad

Browse files
authored
Fix content security policy failure due to <script> tags without nonce generated by HtmlDumper (php-debugbar#563)
1 parent 1bee671 commit 61d4cad

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/DebugBar/JavascriptRenderer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,10 @@ public function render($initialize = true, $renderStackedData = true)
10461046

10471047
$nonce = $this->getNonceAttribute();
10481048

1049+
if ($nonce != '') {
1050+
$js = preg_replace("/<script>/", "<script nonce='{$this->cspNonce}'>", $js);
1051+
}
1052+
10491053
if ($this->useRequireJs){
10501054
return "<script type=\"text/javascript\"{$nonce}>\nrequire(['debugbar'], function(PhpDebugBar){ $js });\n</script>\n";
10511055
} else {

0 commit comments

Comments
 (0)