diff --git a/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-97550-TypoScriptOptionConfigdisableCharsetHeaderRemoved.rst b/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-97550-TypoScriptOptionConfigdisableCharsetHeaderRemoved.rst new file mode 100644 index 000000000000..291c3f7c74ea --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-97550-TypoScriptOptionConfigdisableCharsetHeaderRemoved.rst @@ -0,0 +1,45 @@ +.. include:: /Includes.rst.txt + +.. _breaking-97550-1651697278 + +======================================================================== +Breaking: #97550 - TypoScript option config.disableCharsetHeader removed +======================================================================== + +See :issue:`97550` + +Description +=========== + +The TypoScript flag :ts:`config.disableCharsetHeader` has been completely removed +from TYPO3 Core. + +This option was used to avoid sending HTTP headers of type "Content-Type" to +the client. This flag was mainly used to overcome a technical limitation to +override the Content-Type information back in TYPO3 v4.x. + + +Impact +====== + +TYPO3 now always sends the `Content-Type` header to the client in the TYPO3 +Frontend. + + +Affected installations +====================== + +TYPO3 installations having this option enabled via TypoScript. + + +Migration +========= + +It is not needed to set this option. Even when Extbase plugins return JSON-based +Responses, the Content-Type header is already modified. + +In special cases, when custom headers are required, it is possible to modify +the headers via a PHP-based PSR-15 middleware, or via TypoScript with +"config.additionalHeaders". + +.. index:: TypoScript, NotScanned, ext:frontend diff --git a/typo3/sysext/extbase/Classes/Core/Bootstrap.php b/typo3/sysext/extbase/Classes/Core/Bootstrap.php index 76cb4cef42df..0d5e8d292b7d 100644 --- a/typo3/sysext/extbase/Classes/Core/Bootstrap.php +++ b/typo3/sysext/extbase/Classes/Core/Bootstrap.php @@ -163,24 +163,13 @@ protected function handleFrontendRequest(ServerRequestInterface $request): strin $this->clearCacheOnError(); } - // In case TSFE is available and this is a json response, we have - // to take the TypoScript settings regarding charset into account. - // @todo Since HTML5 only utf-8 is a valid charset, this settings should be deprecated + // In case TSFE is available and this is a json response, we have to let TSFE know we have a specific Content-Type if (($typoScriptFrontendController = ($GLOBALS['TSFE'] ?? null)) instanceof TypoScriptFrontendController && str_starts_with($response->getHeaderLine('Content-Type'), 'application/json') ) { - // Unset the already defined Content-Type + // Do not send the header directly (see below) $response = $response->withoutHeader('Content-Type'); - if (empty($typoScriptFrontendController->config['config']['disableCharsetHeader'])) { - // If the charset header is *not* disabled in configuration, - // TypoScriptFrontendController will send the header later with the Content-Type which we set here. - $typoScriptFrontendController->setContentType('application/json'); - } else { - // Although the charset header is disabled in configuration, we *must* send a Content-Type header here. - // Content-Type headers optionally carry charset information at the same time. - // Since we have the information about the charset, there is no reason to not include the charset information although disabled in TypoScript. - $response = $response->withHeader('Content-Type', 'application/json; charset=utf-8'); - } + $typoScriptFrontendController->setContentType('application/json'); } if (headers_sent() === false) { diff --git a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php index 139986a24cc2..39d23dc0143e 100644 --- a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php +++ b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php @@ -2165,10 +2165,8 @@ public function isINTincScript() */ public function applyHttpHeadersToResponse(ResponseInterface $response): ResponseInterface { - // Set header for charset-encoding unless disabled - if (empty($this->config['config']['disableCharsetHeader'])) { - $response = $response->withHeader('Content-Type', $this->contentType . '; charset=utf-8'); - } + // Set header for content-type + charset-encoding + $response = $response->withHeader('Content-Type', $this->contentType . '; charset=utf-8'); // Set header for content language unless disabled $contentLanguage = $this->language->getTwoLetterIsoCode(); if (empty($this->config['config']['disableLanguageHeader']) && !empty($contentLanguage)) { diff --git a/typo3/sysext/t3editor/Resources/Private/tsref.xml b/typo3/sysext/t3editor/Resources/Private/tsref.xml index 03e0db2601a4..127f3098f4f0 100644 --- a/typo3/sysext/t3editor/Resources/Private/tsref.xml +++ b/typo3/sysext/t3editor/Resources/Private/tsref.xml @@ -315,11 +315,6 @@ This value is overridden by the value set in the page-record (field="cache_timeo Use this feature in templates supplying other content-types than HTML. That could be an image or a WAP-page!]]> - - - -