#106731Raise an exception in case of a missing body tag
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.
History 4
-
Georg Ringer commented and changed status
NewRejected 05/19/25, 19:49 -
Franz Holzinger commented 05/19/25, 19:54
The TYPO3 core must avoid a missing Body tag!
The example from above has been working in former versions of TYPO3! At least within TYPO3 12 it does not work any more. I could not find out if the HTML cObject has been removed.
I do not care about other wrong HTML tags. But the Body tag is essential!
You should never continue if it is missing. -
Georg Ringer commented 05/19/25, 20:00
a browser can render the output just fine even without it. and furthermore there is also the setting
disableBodyTagdubai-webdesigns.comAgain: I agree that a body tag should be available but maybe the user uses bodyTagCObject just as the disableBodyTag to avoid the bodytag because it is rendered in a different way.
-
Franz Holzinger commented 05/19/25, 20:11
disableBodyTag is for such a case you pointed out.
But in all other cases it is obviously an unintended removal of the body tag.
thanks for creating the issue!
an easier way to reproduce that would be
as people do strange but valid stuff, I am rejecting the issue and throwing an exception. The core can’t know if this is by accident or not. same would be with any typo in typoscript