|  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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: info at lauta dot media
New email:
PHP Version: OS:


 [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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 06:01:30 2024 UTC