ExtensionMimeTypeGuesser::guessMimeType must support file names with "0" (zero) like foo.0.zip

Created on 14 November 2024, about 1 month ago

Problem/Motivation

When uploading a file with "0" (zero) as a part of its name, the file is marked incorrectly as application/octet-stream instead of its real mimetype.

This is because when the file name contains a "0" (zero) between dots, guessMimeType() from the ExtensionMimeTypeGuesser class returns NULL prematurely.

Steps to reproduce

  1. Have a file media entity.
  2. Upload a file named foo.0.zip. (No need to save the media entity.)
  3. Go to the Content > Files list.
  4. The uploaded file is marked as application/octet-stream instead of application/zip.

Proposed resolution

Fix the "while" condition in guessMimeType to exit only if array_shift returns NULL.

Remaining tasks

User interface changes

None.

Introduced terminology

None.

API changes

None.

Data model changes

None.

Release notes snippet

๐Ÿ› Bug report
Status

Active

Version

10.3 โœจ

Component

file system

Created by

๐Ÿ‡ซ๐Ÿ‡ทFrance dakwamine

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024