Bug #80590 [Fbk->Csd]: Finfo reports wrong mime type for MP3 files with ID3v1 tags
| From: | info at lauta dot media | Date: | Tue, 05 Jan 2021 16:20:00 +0000 |
| Subject: | Bug #80590 [Fbk->Csd]: 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-231380@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
User updated by: info at lauta dot media
Reported by: info at lauta dot media
Summary: Finfo reports wrong mime type for MP3 files with
ID3v1 tags
-Status: Feedback
+Status: Closed
Type: Bug
Package: *Directory/Filesystem functions
Operating System: Ubuntu 20.04.1 LTS
PHP Version: 8.0.0
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Confirmed that the same also happens with file 5.39, so it is an upstream bug then.
Closing the issue.
Previous Comments:
------------------------------------------------------------------------
[2021-01-05 15:17:27] cmb@php.net
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.
------------------------------------------------------------------------
[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