Breaking: #96221 - Deny inline JavaScript in FormEngine's requireJsModules
See forge#96221
Description
Custom
Form
components allowed to load RequireJS modules
with arbitrary inline JavaScript to initialize those modules. In favor
of introducing content security policy headers, the amount of inline
JavaScript shall be reduced and replaced by corresponding declarations.
Using callback functions as inline JavaScript is not possible anymore,
initializations have to be declared using an instance of
\TYPO3\
.
Impact
Using inline JavaScript to initialize RequireJS modules in Form
,
like shown in the example below, will throw a corresponding
\Logic
.
$resultArray['requireJsModules'][] = ['TYPO3/CMS/Backend/FormEngine/Element/InputDateTimeElement' => '
// inline JavaScript code to initialize `InputDateTimeElement`
function(InputDateTimeElement) {
new InputDateTimeElement(' . GeneralUtility::quoteJSvalue($fieldId) . ');
}'
];
Affected Installations
All instances that are using RequireJS modules with custom initializations
as inline JavaScript in Form
.
Migration
Previous deprecation ChangeLog documentation provided migration details already.
The following snippet shows the migrated source code of shown above - using
\TYPO3\
instead of inline JavaScript.
// use use TYPO3\CMS\Core\Page\JavaScriptModuleInstruction;
$resultArray['requireJsModules'][] = JavaScriptModuleInstruction::forRequireJS(
'TYPO3/CMS/Backend/FormEngine/Element/InputDateTimeElement'
)->instance($fieldId);
Java
forwards arguments as JSON
data - and thus
handles proper context-aware encoding implicitly (
General
and similar custom encoding can be omitted in this case).