Review main Ready for review

97467[BUGFIX] Map MIME types of uploads by the target file extension

Benni Mack CR -1 V +1 Easy +49 −1 updated 11/10/26, 09:22

Commit message

Uploaded files are stored as temporary files without a file
extension. FileInfo::getMimeType() looked up the configured
"fileExtensionToMimeType" mapping by the extension of that temporary
file, so the mapping never applied to uploads.

The extension of the target file name is now used for the lookup
when one is given.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 1
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/67/97467/1 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/67/97467/1 && git cherry-pick FETCH_HEAD

Review

  • Code review CR -1 Needs a vote
    • Georg Ringer +1
    • Josua Vogel -1
  • Verified V +1 Needs a vote
    • Georg Ringer +1
    • core-ci +1 CI

Merge conflicts 1

Issues 1

Files 2

Review log 45

  1. Benni Mack uploaded patch set 1 11/09/26, 19:16

  2. core-ci voted on patch set 1 V +1 11/09/26, 19:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/113766

  3. Benni Mack marked it ready for review 11/09/26, 20:29

  4. Georg Ringer voted on patch set 1 CR +1 V +1 11/09/26, 20:54

  5. Josua Vogel commented on patch set 1 CR -1 11/10/26, 08:48

    Unresolved

    The AI review found the following problem, I need to check it myself: The target-extension mapping can make the consistency check trust the upload filename - **Where:** `typo3/sysext/core/Classes/Type/File/FileInfo.php:41` - **Observed:** `getMimeType()` now uses the target filename’s extension for `fileExtensionToMimeType`; `ResourceConsistencyService` uses that MIME value in its upload consistency check. - **Rule:** The MIME/extension cross-check is intended to guard against disguised uploads by checking detected content — `typo3_documentation_lookup(page="https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/Extbase/Validation/BuiltIn.html#extbase-validation-builtin-fileextensionmimetypeconsistency")`. - **Consequence:** On installations that configure a mapping such as `jpg => image/jpeg`, non-JPEG content named `.jpg` can pass the default-on consistency check. A temporary probe confirmed a plain-text upload did not raise the expected consistency exception. - **Remediation:** Keep the MIME value used for consistency validation derived from file content; apply extension mappings only when content detection is generic or fails. - **Introduced:** by this patch - **Evidence:** verified: a temporary functional probe with plain text, `upload.jpg`, and `jpg => image/jpeg` was accepted; the check’s callers were traced through `ResourceConsistencyService` and `ResourceStorage`.