Review main Merged

89603[BUGFIX] Evaluate mixed-case file extensions in mime_type migration

Garvin Hicking CR +2 V +2 Easy +2 −2 updated 06/10/25, 08:26

Commit message

The SysFileMimeTypeMigration wizard evaluates the database
result set of existing mis-matching MIME-type / file extension
pairs so they can be mapped to proper types.

This failed to recognize though that due to the default
collations being set to "ci" (case insensitive) in most
RDBMS setups, the wizard might receive a valid database
result set of a file extensions set to "CSV" (instead of
"csv"). It would then fail to be able to look up the
lowercase-based $mimeTypeCompatibility array.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Stefan Bürk +1
    • Oliver Hader +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Stefan Bürk +1
    • Oliver Hader +1
    • core-ci +1 CI

Issues 2

Files 1

Review log 1315

  1. Garvin Hicking uploaded patch set 1 06/02/25, 10:55

  2. Ivan Dharma Kartolo voted on patch set 1 CR +1 06/02/25, 11:01

  3. core-ci voted on patch set 1 V +1 06/02/25, 11:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/79744

  4. Benjamin Franzke uploaded patch set 2 CR +1 V +1 06/03/25, 06:49

  5. Benjamin Franzke commented on patch set 2 06/03/25, 06:49

    SysFileMimeTypeMigration.php:115

    I don't think there's a mime type in uppercase in db.
  6. core-ci voted on patch set 2 V +1 06/03/25, 06:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/79788

  7. Garvin Hicking commented on patch set 2 06/03/25, 09:30

    SysFileMimeTypeMigration.php:115 Reply

    The way I understood this is that the Mimetype there is a user input, so users may input/configure something like "Text/CSV"? According to IANA, Mimetypes are case insensitive, and only lowercase by convention, not mandatory. So IMO we should probably normalize this?
  8. Benjamin Franzke commented on patch set 2 06/03/25, 10:04

    SysFileMimeTypeMigration.php:115 Reply

    the mime_type is detected, not user input. The extension is user input (as it is encoded within the user-provided filename), therefore that could be uppercase, but mime_type was always the one detected within the file contents, therefore it's not uppercase (would only be the case if finfo_file/mime_content_type would report uppercase, which they do not do – otherwise case our new mime_type-has-to-match-extension assertion would already fail during persistence of the file)
  9. Garvin Hicking commented on patch set 2 06/03/25, 12:54

    SysFileMimeTypeMigration.php:115 Reply

    What I meant was the array from getMimeTypeCompatibilityList(). This is populated with data from $GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['mimeTypeCompatibility'] - which I referred to as "user input". Sorry for the impreciseness.
  10. Benjamin Franzke commented on patch set 2 06/10/25, 06:26

    SysFileMimeTypeMigration.php:115 Reply

    Understood, thx. I'd still like to consider that all lowercase, as there is no reason (besides this bug which we're fixing now) that one would configure uppercase extension or mime types. We normalize to lowercase. So I think we're good here with this adaption, thanks!
  11. Garvin Hicking commented on patch set 2 06/10/25, 07:09

    SysFileMimeTypeMigration.php:115 Reply

    Alright. Just wanted to be sure and my reasoning came across. I'm good with this then!
  12. Stefan Bürk voted on patch set 2 CR +1 V +1 06/10/25, 07:57

  13. Oliver Hader voted on patch set 2 CR +1 V +1 06/10/25, 08:25

  14. Benjamin Franzke voted on patch set 2 CR +2 V +2 06/10/25, 08:26

  15. Benjamin Franzke merged patch set 3 06/10/25, 08:26