Commit 3a7c8b13 authored by Benni Mack's avatar Benni Mack
Browse files

[!!!][TASK] Remove typoscript option config.disableCharsetHeader

This option is obsolete nowadays, as PSR-7 is setting
the headers at the end of the script / when emitting
a Response, this way the header can be modified at any time.

Resolves: #97550
Releases: main
Change-Id: I0602e4fd0a20461d49a554f66f36442894e96fd4
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74518

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: default avatarJosef Glatz <josefglatz@gmail.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent ae00ad42
.. 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
......@@ -163,24 +163,13 @@ class Bootstrap
$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) {
......
......@@ -2165,10 +2165,8 @@ class TypoScriptFrontendController implements LoggerAwareInterface
*/
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)) {
......
......@@ -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!]]></description>
<default><![CDATA[false]]></default>
</property>
<property name="disableCharsetHeader" type="boolean">
<description><![CDATA[By default a HTTP header "Content-Type: text/html; charset..." is sent. This option will disable that.]]></description>
<default><![CDATA[
]]></default>
</property>
<property name="disablePrefixComment" type="boolean">
<description><![CDATA[If set, the stdWrap property "prefixComment" will be disabled, thus preventing any revealing and spaceconsuming comments in the HTML source code.]]></description>
<default><![CDATA[
......
......@@ -255,7 +255,6 @@
'disableAllHeaderCode': kw('disableAllHeaderCode'),
'disableAltText': kw('disableAltText'),
'disableBodyTag': kw('disableBodyTag'),
'disableCharsetHeader': kw('disableCharsetHeader'),
'disabled': kw('disabled'),
'disableDelete': kw('disableDelete'),
'disableHideAtCopy': kw('disableHideAtCopy'),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment