Issue Bug Rejected

#106731Raise an exception in case of a missing body tag

Franz Holzinger 05/19/25, 19:36 updated 05/19/25, 20:11

Description

Due to some changes in TYPO3 it has turned out that the body tag has been missing on the page HTML.

E.g.

page = PAGE
page {
typeNum = 0
shortcutIcon = EXT:myExtension/Resources/Public/Icons/favicon.ico
bodyTagCObject = HTML
bodyTagCObject {
value.field = uid
value.wrap = <body id=“page|”>
}

has the result, that the “<body>“ tag is completely missing at the end.<br>This is invalid HTML which should never be generated.<br>An exception should be thrown instead.</body>

typo3_src-12.4.30-debug/typo3/sysext/frontend/Classes/Http/RequestHandler.php:

if ($controller->config[‘config’][‘disableBodyTag’] ?? false) {
$bodyTag = ‘’;
} else {
$defBT = (isset($controller->pSetup[‘bodyTagCObject’]) && $controller->pSetup[‘bodyTagCObject’])
? $controller->cObj->cObjGetSingle($controller->pSetup[‘bodyTagCObject’], $controller->pSetup[‘bodyTagCObject.’] ?? [], ‘bodyTagCObject’)
: ‘<body>’;
$bodyTag = (isset($controller->pSetup[‘bodyTag’]) && $controller->pSetup[‘bodyTag’])
? $controller->pSetup[‘bodyTag’]
: $defBT;
if (trim($controller->pSetup[‘bodyTagAdd’] ?? ‘’)) {
$bodyTag = preg_replace(‘/>$/’, ‘’, trim($bodyTag)) . ‘ ‘ . trim($controller->pSetup[‘bodyTagAdd’]) . ‘>’;
}
}
$pageRenderer->addBodyContent(LF . $bodyTag);

If the TypoScript causes the $bodyTag to be an empty string, then TYPO3 should not continue at this point, but raise an exception with the TypoScript as details.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.