|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80590 Finfo reports wrong mime type for MP3 files with ID3v1 tags
Submitted: 2021-01-05 10:50 UTC Modified: 2021-01-05 16:29 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: info at lauta dot media Assigned: cmb (profile)
Status: Not a bug Package: *Directory/Filesystem functions
PHP Version: 8.0.0 OS: Ubuntu 20.04.1 LTS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
4 - 1 = ?
Subscribe to this entry?

 [2021-01-05 10:50 UTC] info at lauta dot media
mime_content_type() and finfo reports mime type application/octet-stream for MP3 files with ID3v1 tags. ID3v1 seems to be used in up to 10% of all MP3 files which have any ID3 tags.

This seems to be an issue with PHP built in magic.mime. Using a custom magicfile with finfo with just the below contents reports the mime type for those files correctly.

For the avoidance of doubt file -i also reports the wrong mime type unless I add the rows below to /etc/magic, so this might actually be an upstream bug.
id3v1.mp3: application/octet-stream; charset=binary

# for the test script the following is the file 'mp3id3v1_magic.mime'.
0       string      ID3     audio/mpeg
!:mime  audio/mpeg

Test script:
echo mime_content_type('id3v1.mp3') . "\n";

$finfo = new finfo(FILEINFO_MIME_TYPE);
echo $finfo->file($filePath) . "\n";

$finfo = new finfo(FILEINFO_MIME_TYPE, 'mp3id3v1_magic.mime');
echo $finfo->file($filePath) . "\n";

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-05 15:17 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-01-05 15:17 UTC]
If file 5.39 reports the same MIME types, this would indeed be an
upstream issue.  In this case, please report it there.

Otherwise, please provide the sample file for download from the
 [2021-01-05 16:20 UTC] info at lauta dot media
-Status: Feedback +Status: Closed
 [2021-01-05 16:20 UTC] info at lauta dot media
Confirmed that the same also happens with file 5.39, so it is an upstream bug then.

Closing the issue.
 [2021-01-05 16:29 UTC]
-Status: Closed +Status: Not a bug
 [2021-01-05 16:29 UTC]
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Dec 01 10:05:53 2022 UTC