Describe the bug
While working with the TYPO3 Headless extension, I noticed that JSON data in some places is generated using string concatenation. This approach can occasionally result in unintended JSON structures, especially if the input data contains unexpected characters. For example, when using pages.abstract, the concatenation may lead to malformed or invalid JSON output.
To Reproduce
Steps to reproduce the behavior:
Configure the TYPO3 Headless extension to use pages.abstract in the TypoScript JSON generation.
Provide input data in pages.abstract containing characters like: >>>","example":{"unexpected":true},"end":"<<<.
Observe the generated JSON output.
Notice that the concatenated JSON might not produce the expected or valid structure.
Expected behavior
To ensure the JSON output is always correct and well-formed, it would be great to use programmatic methods for building JSON (e.g., serialization tools) instead of relying on string concatenation. This can help manage escaping and ensure that all data integrates seamlessly.
Using concatenation works in many cases, but there’s a risk of unintentional results when input data includes special characters or formatting. A programmatic approach to building JSON (using serialization libraries or helper functions) would make this process more robust and predictable.
Describe the bug
While working with the TYPO3 Headless extension, I noticed that JSON data in some places is generated using string concatenation. This approach can occasionally result in unintended JSON structures, especially if the input data contains unexpected characters. For example, when using
pages.abstract
, the concatenation may lead to malformed or invalid JSON output.To Reproduce
Steps to reproduce the behavior:
pages.abstract
in the TypoScript JSON generation.pages.abstract
containing characters like:>>>","example":{"unexpected":true},"end":"<<<
.Expected behavior
To ensure the JSON output is always correct and well-formed, it would be great to use programmatic methods for building JSON (e.g., serialization tools) instead of relying on string concatenation. This can help manage escaping and ensure that all data integrates seamlessly.
Additional context
The functionality is defined in this TypoScript configuration:
https://github.com/TYPO3-Headless/headless/blob/master/Configuration/TypoScript/ContentElement/MenuAbstract.typoscript#L19-L20
Using concatenation works in many cases, but there’s a risk of unintentional results when input data includes special characters or formatting. A programmatic approach to building JSON (using serialization libraries or helper functions) would make this process more robust and predictable.