Skip to content

Replace generated media type map with hand-maintained array - #2489

Open
jimsafley wants to merge 1 commit into
developfrom
refactor/media-type-map
Open

jimsafley wants to merge 1 commit into
developfrom
refactor/media-type-map

Conversation

@jimsafley

Copy link
Copy Markdown
Member

See #2488

The media type map (used to guess file extensions from MIME types when an uploaded file has no extension) was previously generated by fetching Apache's mime.types and converting it via a script. This worked but had drawbacks: alphabetical ordering from Apache meant poor extension choices (e.g. mpga instead of mp3), an override system was needed to paper over those choices, and the array format was raw var_export output.

This replaces that tooling with a hand-maintained array:

  • Drops the generation script, gulp task, and CS fixer exclusion
  • Moves the file next to the factory that uses it
  • Simplifies from string => string[] to string => string (the map is only used for extension guessing, not validation)
  • Chooses conventional extensions throughout rather than deferring to Apache's alphabetical order
  • Comments out obscure types unlikely to be uploaded, while keeping all original entries in the file for reference
  • Ensures all types and extensions in the upload allowlists have active entries
  • Adds the following types that were in the allowlist but absent from the Apache source:
    • application/vnd.ms-access → mdb
    • application/vnd.ms-write → wri
    • application/x-gzip → gz
    • application/x-ms-wmp → wmp
    • audio/opus → opus
    • audio/x-realaudio → ra
    • image/pjpeg → jpg
    • video/divx → divx

Drop the Apache-fetching script, gulp task, and override file in favor
of a single hand-maintained string => string map co-located with its
factory. Prune obscure types to active entries, ensure all whitelisted
types are covered.

Closes #2488
@jimsafley
jimsafley requested a review from zerocrates May 9, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant