Skip to content

Commit 4d9f476

Browse files
linawolfgarvinhickingfroemken
authored
[BUGFIX] Fix file uploads where concrete MIME types can't be determined (#5886)
* [BUGFIX] Fix file uploads where concrete MIME types can't be determined Resolves: TYPO3-Documentation/Changelog-To-Doc#1255 Releases: main, 13.4, 12.4 * Apply suggestion from @garvinhicking * Update Documentation/Configuration/Typo3ConfVars/SYS.rst --------- Co-authored-by: Garvin Hicking <[email protected]> Co-authored-by: Stefan Frömken <[email protected]>
1 parent e9be3e8 commit 4d9f476

File tree

1 file changed

+44
-13
lines changed
  • Documentation/Configuration/Typo3ConfVars

1 file changed

+44
-13
lines changed

Documentation/Configuration/Typo3ConfVars/SYS.rst

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -930,25 +930,56 @@ configurations.
930930
:name: globals-typo3-conf-vars-sys-FileInfo-fileExtensionToMimeType
931931
:Path: $GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType']
932932
:type: array
933-
:Default: see :file:`EXT:core/Configuration/DefaultConfiguration.php`
934933

935-
Static mapping for file extensions to mime types. In special cases the mime
936-
type is not detected correctly. Override this array only for cases where the
937-
automatic detection does not work correctly!
934+
.. versionchanged:: 13.4.13 / 12.4.32
935+
This file extension-based MIME type mapping is now superseded
936+
by the more fine-grained MIME type compatibility list
937+
`$GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['mimeTypeCompatibility'] <https://docs.typo3.org/permalink/t3coreapi:confval-globals-typo3-conf-vars-sys-fileinfo-mimetypecompatibility>`_.
938938

939-
It is not possible to change this value in the Backend!
939+
`$GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType']`
940+
is supported for backward compatibility reasons.
940941

941-
This is the default:
942+
.. _typo3ConfVars-sys-FileInfo-mimeTypeCompatibility:
943+
944+
.. confval:: mimeTypeCompatibility
945+
:name: globals-typo3-conf-vars-sys-FileInfo-mimeTypeCompatibility
946+
:Path: $GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['mimeTypeCompatibility']
947+
:type: array
948+
:Default: see `EXT:core/Configuration/DefaultConfiguration.php <https://github.com/TYPO3/typo3/blob/006db645e4716529390fc3f07d84fe36b8694c43/typo3/sysext/core/Configuration/DefaultConfiguration.php#L369>`_
949+
950+
.. versionadded:: 13.4.13 / 12.4.32
951+
This mapping supersedes
952+
`$GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType'] <https://docs.typo3.org/permalink/t3coreapi:confval-globals-typo3-conf-vars-sys-fileinfo-fileextensiontomimetype>`_
953+
954+
For each generic MIME type (as detected by PHP MIME type detection) a
955+
map from file extension to allowed concrete MIME type can be supplied.
956+
957+
The Core predefines common file extensions and MIME types. Custom ones
958+
can be configured additionally.
959+
960+
Since PHP file detection methods can not reliable detect all IANA defined MIME
961+
types, mime-db based heuristics are applied to map generic MIME types like
962+
`text/plain` to `text/csv` for `*.csv` files.
963+
964+
Example that is already shipped with TYPO3, a `*.jfif` file that is
965+
detected as image/jpeg is mapped to image/pjpeg, which is the
966+
defined MIME type per IANA and enforced by the FAL persistence layer.
942967

943968
.. code-block:: php
969+
:caption: Example from the TYPO3 Core
944970
945-
$GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType'] = [
946-
'fileExtensionToMimeType' => [
947-
'svg' => 'image/svg+xml',
948-
'youtube' => 'video/youtube',
949-
'vimeo' => 'video/vimeo',
950-
],
951-
],
971+
$GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['mimeTypeCompatibility']['image/jpeg']['jfif'] =
972+
'image/pjpeg';
973+
974+
Generic example, which allows a file ending in `*.foo` that is detected
975+
to contain text/plain contents to be mapped to the MIME type text/x-foo,
976+
other contents (e.g. if the file contains binary data) will not be mapped
977+
978+
.. code-block:: php
979+
:caption: config/system/additional.php
980+
981+
$GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['mimeTypeCompatibility']['text/plain']['foo'] =
982+
'text/x-foo';
952983
953984
.. confval:: allowedPhpDisableFunctions
954985
:name: globals-typo3-conf-vars-sys-allowedPhpDisableFunctions

0 commit comments

Comments
 (0)