php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79681 mime_content_type/finfo returning incorrect mimetype
Submitted: 2020-06-08 11:19 UTC Modified: 2020-06-09 13:49 UTC
Votes:3
Avg. Score:3.7 ± 1.2
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:0 (0.0%)
From: xandros92 at gmail dot com Assigned: cmb (profile)
Status: Closed Package: *Directory/Filesystem functions
PHP Version: 7.4.6 OS: Windows 10 1909
Private report: No CVE-ID: None
 [2020-06-08 11:19 UTC] xandros92 at gmail dot com
Description:
------------
After change php version from 7.3 and 7.2 to 7.4, some applications failed validation uploaded files on mimetype. The problem exist with some audio/mpeg and application/x-gzip.

Test script:
---------------
echo finfo_file(finfo_open(), __DIR__ . '/sample.xml.gz', FILEINFO_MIME);
echo finfo_file(finfo_open(), __DIR__ . '/sample.mp3, FILEINFO_MIME);

Expected result:
----------------
application/x-gzip; charset=binary
audio/mpeg; charset=binary


Actual result:
--------------
application/gzip; charset=binary
application/x-font-gdos; charset=binary


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-06-08 12:33 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-06-08 12:33 UTC] cmb@php.net
Can you please make sample.xml.gz and sample.mp3 available for download?
 [2020-06-09 13:49 UTC] cmb@php.net
-Status: Feedback +Status: Analyzed
 [2020-06-09 13:49 UTC] cmb@php.net
Thanks for the samples!

I can confirm the behavior.  Reporting the .xml.gz as
application/gzip is actually an improvement, since this mime type
is registered[1]. Reporting the .mp3 as application/x-font-gdos is
obviously wrong, and has been fixed[2] for file 5.38.

[1] <https://www.iana.org/assignments/media-types/media-types.xhtml>
[2] <https://github.com/file/file/commit/5a55569a35eff686d4b7400b219d380f7c622890>
 [2020-06-10 14:41 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6747068ce716ca9e458b245489086d7ff13109b9
Log: Fix #79681: mime_content_type/finfo returning incorrect mimetype
 [2020-06-10 14:41 UTC] cmb@php.net
-Status: Analyzed +Status: Closed
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Aug 11 01:01:25 2020 UTC