Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save astehlik/8105e17bd237448003f344345b0b398d to your computer and use it in GitHub Desktop.
Save astehlik/8105e17bd237448003f344345b0b398d to your computer and use it in GitHub Desktop.
--- Classes/Page/PageRenderer.php 2023-05-11 10:41:55.206722544 +0200
+++ Classes/Page/PageRenderer.php 2023-05-11 10:34:43.011841844 +0200
@@ -2145,7 +2145,7 @@
if ($this->getApplicationType() === 'BE') {
$this->javaScriptRenderer->addGlobalAssignment(['TYPO3' => $assignments]);
} else {
- // @todo apply nonce for CSP (means dropping static `inlineJavascriptWrap`)
+ $attributes = $this->nonce !== null ? ['nonce' => $this->nonce->consume()] : [];
$out .= $this->wrapInlineScript(
sprintf(
"var TYPO3 = Object.assign(TYPO3 || {}, %s);\r\n",
@@ -2155,7 +2155,8 @@
. "!['__proto__', 'prototype', 'constructor'].includes(entry[0])))",
json_encode($assignments)
)
- )
+ ),
+ $attributes
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment