Review 12.4 Merged

90014[BUGFIX] Allow replacing files with different mime-type and extension

Oliver Hader CR +2 V +2 Normal +120 −29 updated 07/08/25, 08:39

Commit message

Replacing an existing file.pdf (having mime-type `application/pdf`)
with another file.png (having mime-type `image/png`) is denied due
to the mismatching mime-type to extension consistency check.

The file abstraction layer performed two distinct operations
(first replace file contents, then rename file name) which caused
this problem.

The new `ResourceStorage::replaceAndRenameUploadedFile()` method is
dedicated for that purpose, enabling the resource storage to
know about the overall intention and allowing to perform a proper
consistency check.

In case the flag "keep the current filename" is enabled in the user
interface, the filename part is kept, however the fileextension is
adjusted if necessary.

As a drive-by change, the resource integrity error messages are
now properly revelead in errors stemming from the "Rename" action.
This is implemented without the need for a XLF label change just by
string concatenation.

Review

  • Code review CR +2 Done
    • Oliver Hader +2
  • Verified V +2 Done
    • Oliver Hader +2
    • core-ci +1 CI

Issues 1

Files 7

Review log 711

  1. Oliver Hader uploaded patch set 1 07/08/25, 07:52

  2. core-ci voted on patch set 1 V -1 07/08/25, 08:04 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81465

  3. Oliver Hader uploaded patch set 2 V -1 07/08/25, 08:08

  4. core-ci voted on patch set 2 V -1 07/08/25, 08:16 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81468

  5. Oliver Hader uploaded patch set 3 V -1 07/08/25, 08:25

  6. Oliver Hader commented on patch set 3 CR -1 07/08/25, 08:32

    ResourceStorage.php:2064

    Drop this, as it has not been there before...
  7. Oliver Hader uploaded patch set 4 CR -1 07/08/25, 08:33

  8. core-ci voted on patch set 3 V +1 07/08/25, 08:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81473

  9. core-ci voted on patch set 4 V +1 07/08/25, 08:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81474

  10. Oliver Hader voted on patch set 4 CR +2 V +2 07/08/25, 08:39

  11. Oliver Hader merged patch set 5 07/08/25, 08:39