diff --git a/typo3/sysext/core/Classes/Page/PageRenderer.php b/typo3/sysext/core/Classes/Page/PageRenderer.php
index 9b1c3e1b4d03..29967f481a8a 100644
--- a/typo3/sysext/core/Classes/Page/PageRenderer.php
+++ b/typo3/sysext/core/Classes/Page/PageRenderer.php
@@ -1594,22 +1594,32 @@ protected function getRequireJsLoader(): string
}
$requireJsUri = $this->processJsFile($this->requireJsPath . 'require.js');
// add (probably filtered) RequireJS configuration
+ $commonAttributes = $this->nonce !== null ? ['nonce' => $this->nonce->consume()] : [];
if ($this->getApplicationType() === 'BE') {
$html .= sprintf(
- '' . "\n",
- htmlspecialchars($requireJsUri)
+ '' . "\n",
+ GeneralUtility::implodeAttributes([
+ ...$commonAttributes,
+ 'src' => $requireJsUri,
+ ], true)
);
$html .= sprintf(
- '' . "\n",
- htmlspecialchars($this->getStreamlinedFileName('EXT:core/Resources/Public/JavaScript/require-jsconfig-handler.js', true)),
+ '' . "\n",
+ GeneralUtility::implodeAttributes([
+ ...$commonAttributes,
+ 'src' => $this->getStreamlinedFileName('EXT:core/Resources/Public/JavaScript/require-jsconfig-handler.js'),
+ ], true),
(string)json_encode($requireJsConfig, JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG)
);
} else {
$html .= GeneralUtility::wrapJS('var require = ' . json_encode($requireJsConfig)) . LF;
// directly after that, include the require.js file
$html .= sprintf(
- '' . "\n",
- htmlspecialchars($requireJsUri)
+ '' . "\n",
+ GeneralUtility::implodeAttributes([
+ ...$commonAttributes,
+ 'src' => $requireJsUri,
+ ], true)
);
}
// use (anonymous require.js loader). Used to shim ES6 modules and when not
@@ -1618,12 +1628,13 @@ protected function getRequireJsLoader(): string
($this->getApplicationType() === 'BE' && $this->javaScriptRenderer->hasImportMap()) ||
!empty($requireJsConfig['typo3BaseUrl'])
) {
- $html .= '' . LF;
+ $html .= sprintf(
+ '' . "\n",
+ GeneralUtility::implodeAttributes([
+ ...$commonAttributes,
+ 'src' => $this->getStreamlinedFileName('EXT:core/Resources/Public/JavaScript/requirejs-loader.js'),
+ ], true)
+ );
}
return $html;