Skip to content
Snippets Groups Projects
Commit a868e52d authored by Benjamin Franzke's avatar Benjamin Franzke
Browse files

[BUGFIX] Prevent possible browser freezes in FormEditor

Using timestamps as array keys in form yaml configuration
can result in sparse [1] JavaScript arrays which contain
"empty slots".

Example yaml configuration:

  templateRootPaths:
    1708504268: 'EXT:example/Resources/Private/Emails/Templates'

This value is properly serialized into an object by PHP json_encode
(as it does not contain sequential integer keys starting at 0), but
the FormEditor data model produces arrays from numerical keys during
clone operations of such data sets and basically creates sparse arrays
like:

> const example = []
> example[1708504268] = 'EXT:example/Resources/Private/Emails/Templates'
> console.log(example)
[
  <1708504268 empty items>,
  'EXT:forms_extended/Resources/Private/Emails/Templates'
]

Some array-looping operations like Array.reduce() will loop through all
empty slots [1] and therefore preduce a lot of processing load
(1708504269 loops for the example above) that ultimately cause freezes.

The array to object copy operation is now replaced by a modern spread
operation that is defined to skip empty slots.

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#sparse_arrays

Releases: main, 12.4, 11.5
Resolves: #103168
Change-Id: I10b586ff5c5b0fb3698bfbbe28b2f93d932b71a2
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83079


Reviewed-by: default avatarBenjamin Franzke <ben@bnf.dev>
Tested-by: default avatarBenjamin Franzke <ben@bnf.dev>
Tested-by: default avatarcore-ci <typo3@b13.com>
parent 46037481
Branches
Tags
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment