php.net |  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
Votes:2
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
 [2021-01-05 10:50 UTC] 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



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-05 15:17 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-01-05 15:17 UTC] 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 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] cmb@php.net
-Status: Closed +Status: Not a bug
 [2021-01-05 16:29 UTC] cmb@php.net
Thanks!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 07:01:29 2024 UTC