|  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: 2021-01-05 15:50 UTC
Avg. Score:3.6 ± 1.0
Reproduced:4 of 4 (100.0%)
Same Version:4 (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
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-06-08 12:33 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-06-08 12:33 UTC]
Can you please make sample.xml.gz and sample.mp3 available for download?
 [2020-06-09 13:49 UTC]
-Status: Feedback +Status: Analyzed
 [2020-06-09 13:49 UTC]
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] <>
[2] <>
 [2020-06-10 14:41 UTC]
Automatic comment on behalf of
Log: Fix #79681: mime_content_type/finfo returning incorrect mimetype
 [2020-06-10 14:41 UTC]
-Status: Analyzed +Status: Closed
 [2020-11-19 17:32 UTC] jamier105+php at gmail dot com
Please can this bug be reopened and checked again as I can recreate it using PHP 7.4.12:

$ php7.3 -v
PHP (cli) (built: Oct 31 2020 16:59:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
$ php7.3 -r 'echo finfo_file(finfo_open(), __DIR__ . "/my_file.mp3", FILEINFO_MIME). "\n";'
audio/mpeg; charset=binary

$ php7.4 -v
PHP 7.4.12 (cli) (built: Oct 31 2020 17:04:09) ( NTS )
Copyright (c) The PHP Group
$ php7.4 -r 'echo finfo_file(finfo_open(), __DIR__ . "/my_file.mp3", FILEINFO_MIME). "\n";'
application/x-font-gdos; charset=binary

An example file can be provided if needed.

 [2020-11-19 17:42 UTC]
Please provide the example file! :)
 [2020-11-25 13:50 UTC]
-Status: Closed +Status: Re-Opened
 [2020-11-25 13:50 UTC]
Thanks for the sample file!  I can confirm the reported behavior,
although the sample provided by xandros92 yields the desired
results for PHP 7.3 and 7.4.  This might be a different issue.
Re-opening for now, to keep track of the issue.
 [2021-01-05 15:50 UTC]
-Status: Re-Opened +Status: Closed
 [2021-01-05 15:50 UTC]
It makes no sense to keep this ticket open, since the changelog
already has entries that this issue has been fixed, and quite
obviously, this is yet a different issue.  Therefore I have
reported this as bug #80594.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Mar 03 10:01:29 2024 UTC