Issue Bug Closed

#107470Harden StandardContentPreviewRenderer

Kevin Ditscheid 09/17/25, 09:57 updated 12/02/25, 13:04

Description

Contrary to what the doc-block is saying, the method BackendUtility::getProcessedValue can return something different than string or null. In PHP 8.4, giving an integer value to htmlspecialchars will cause an exception.
To prevent this, the return type of the method in question must either be enforced, or the value in $fieldValue must be explicitly cast to string, before giving it to htmlspecialchars.

The problem popped up for me with gridelements sending something to the StandardContentPreviewRenderer and it checking the header_layout field, which contained integer values.

https://github.com/TYPO3/typo3/blob/13.4/typo3/sysext/backend/Classes/Preview/StandardContentPreviewRenderer.php#L268
https://github.com/TYPO3/typo3/blob/13.4/typo3/sysext/backend/Classes/Utility/BackendUtility.php#L1616

Reviews 2