Review main Merged

89779[BUGFIX] Improve allowed MIME type handling, add vcf handling

Garvin Hicking CR +2 V +2 Easy +19 −4 updated 06/25/25, 13:57

Commit message

The mime-db collection requires .vcf files to have the
MIME type "text/x-vcard", but PHP's `finfo_file` or
`mime_content_type()` reports the MIME type as
"text/vcard", which is the actual RFC6350 recommendation.

With this patch, the MIME type "text/vcard" is added (patched) to
the list of mime-db JSON file containing the file-extension to
MIME-type assignments. This will allow .vcf files to be recognized
for both "text/vcard" (IANA/RFC) and "text/x-vcard" (Apache) variants.

An upstream issue [1] has been created so that ideally the hotfix
will not be required anymore at some point. Depending on that
outcome we might need an upgrade wizard that maps existing
"text/x-vcard" sys_file entries to "text/vcard".

Editor's note matching a sad trombone: Yes, this might happen for other
formats as they are revealed to us. Yes, there is no comprehensive
collection of every MIME type with a matching example files to
easily verify the outcome of PHP's MIME mapping to the db.json
structure.

Additionally, this patch adjusts the output message
for mismatching MIME types to contain the expected
type in the flash message output, so that integrators
can more easily adjust their configuration like this:

```
$GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['mimeTypeCompatibility']
  [<reportedMIMEType>]
  [<fileExtension>] = <expectedMIMEType>;
```

[1] https://github.com/jshttp/mime-db/issues/388

Review

  • Code review CR +2 Done
    • Garvin Hicking +2
    • Benjamin Franzke +1
    • Mogens Fiebrandt +1
    • Oliver Hader +1
  • Verified V +2 Done
    • Garvin Hicking +2
    • Benjamin Franzke +1
    • Mogens Fiebrandt +1
    • Oliver Hader +1
    • core-ci +1 CI

Issues 3

Files 4

Review log 1720

  1. Garvin Hicking uploaded patch set 1 06/20/25, 12:33

  2. core-ci voted on patch set 1 V +1 06/20/25, 12:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/80529

  3. Mogens Fiebrandt voted on patch set 1 CR +1 V +1 06/20/25, 14:36

  4. Benjamin Franzke commented on patch set 1 06/23/25, 09:05

    I do not understand why this patch is needed. When I apply the part of the DefaultConfiguration, the bug is already fixed and vcf can be uploaded. ``` + 'text/vcard' => [ + 'vcf' => 'text/x-vcard', ```
  5. Benjamin Franzke commented on patch set 1 V -1 06/23/25, 09:07

    Reply

    btw, the forge issue used a wrong mapping, `[text/vcard']['vcf'] = 'text/vcard'`, it should have been `[text/vcard']['vcf'] = 'text/x-vcard'` as in your patch.
  6. Benjamin Franzke commented on patch set 1 06/23/25, 09:15

    MimeTypeCompatibilityTypeGuesser.php:86

    The mapping `['text/plain']['vcf'] = 'text/x-vcard'` can coexist with `['text/vcard']['vcf'] = 'text/x-vcard'` as it allows both mime-types (`text/plain` and `text/vcard`) to be mapped to `text/x-vcard`). That means: No matter whether PHP/the server environment detects the `.vcf` as `text/plain` or as `text/vcard`, it will be mapped to `text/x-vcard`.

    ResourceConsistencyService.php:100

    I like ❤️
  7. Garvin Hicking uploaded patch set 2 CR +1 V +1 06/23/25, 14:25

  8. Garvin Hicking commented on patch set 2 06/23/25, 14:29

    MimeTypeCompatibilityTypeGuesser.php:86 Reply

    Thanks. I think you're right. I was quite sure I initially tested it with the proper configuration from the forge issue (with proper identifier) and it didn't work without my lines. I tried to reproduce that and failed; it seems it all works without this change, so I removed it. I rephrased the commit message to try to point out that "mime-db" doesn't comply with the RFC in the vcf resolution. Do you know by chance what else is a mismatch of mime-db with source:apache and what PHP reports? I'm a bit afraid this will be a constant uphill battle to add mappings for file types, and each time we'll have to decide whether the file format is "common" or not to be included in the core....?
  9. core-ci voted on patch set 2 V +1 06/23/25, 14:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/80625

  10. Benjamin Franzke commented on patch set 2 06/23/25, 14:59

    good, catch, I actually trusted mime-db which reports text/vcard to be .vcard only, which source "iana", but both iana and the respective RFC report vcf and vcard to be allowed: https://www.iana.org/assignments/media-types/text/vcard https://www.rfc-editor.org/rfc/rfc6350.html Seems like the mime-db regex fails to pick that up..: https://github.com/jshttp/mime-db/blob/master/scripts/fetch-iana.js#L31 So I think `.vcf` was nothing official, but since it is, we should rather not map to `text/x-vcard`, but either fix (or overwrite) mime-db.
  11. Garvin Hicking commented on patch set 2 06/23/25, 16:00

    Reply

    Rabbit hole :-) I just filed it here: https://github.com/jshttp/mime-db/issues/388
  12. Garvin Hicking uploaded patch set 3 V +1 06/23/25, 16:15

  13. core-ci voted on patch set 3 V +1 06/23/25, 16:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/80644

  14. Benjamin Franzke commented on patch set 3 CR +1 V +1 06/23/25, 20:37

    Reply

    thanks!

    MimeTypeCompatibilityTypeGuesser.php:86 Reply

    I don't know about other mismatches and as we've seens, this is more than just a mismatch, but an upstream bug. Thx for reporting and supplying the fix.
  15. Mogens Fiebrandt voted on patch set 3 CR +1 V +1 06/24/25, 23:28

  16. Oliver Hader voted on patch set 3 CR +1 V +1 06/25/25, 11:40

  17. Oliver Hader commented on patch set 3 06/25/25, 11:40

    In addition: Should `vcf` be added as default to the `textfile_ext` list?
  18. Garvin Hicking voted on patch set 3 CR +2 V +2 06/25/25, 13:09

  19. Garvin Hicking commented on patch set 3 06/25/25, 13:56

    Reply

    (Note, we've talked about this - textfile_ext is already not a full list of supported allowed MIME types and would need alignment if it ever gets enforced by default. For now we'll try to have the list leaner with more common uploaded files)
  20. Garvin Hicking merged patch set 4 06/25/25, 13:57