Bug #80590 [Opn->Fbk]: Finfo reports wrong mime type for MP3 files with ID3v1 tags
| From: | cmb@php.net | Date: | Tue, 05 Jan 2021 15:17:27 +0000 |
| Subject: | Bug #80590 [Opn->Fbk]: Finfo reports wrong mime type for MP3 files with ID3v1 tags | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231377@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80590&edit=1
ID: 80590
Updated by: cmb@php.net
Reported by: info at lauta dot media
Summary: Finfo reports wrong mime type for MP3 files with
ID3v1 tags
-Status: Open
+Status: Feedback
Type: Bug
Package: *Directory/Filesystem functions
Operating System: Ubuntu 20.04.1 LTS
PHP Version: 8.0.0
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
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
Web.
Previous Comments:
------------------------------------------------------------------------
[2021-01-05 10:50:26] info at lauta dot media
Description:
------------
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:
---------------
<?php
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:
----------------
audio/mpeg
audio/mpeg
audio/mpeg
Actual result:
--------------
application/octet-stream
application/octet-stream
audio/mpeg
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80590&edit=1