Bug #80590 [NEW]: Finfo reports wrong mime type for MP3 files with ID3v1 tags

From: Date: Tue, 05 Jan 2021 10:50:26 +0000
Subject: Bug #80590 [NEW]: Finfo reports wrong mime type for MP3 files with ID3v1 tags
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231371@lists.php.net to get a copy of this message
From: info at lauta dot media Operating system: Ubuntu 20.04.1 LTS PHP version: 8.0.0 Package: *Directory/Filesystem functions Bug Type: Bug Bug description:Finfo reports wrong mime type for MP3 files with ID3v1 tags 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 bug report at https://bugs.php.net/bug.php?id=80590&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80590&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80590&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80590&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80590&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80590&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80590&r=support Expected behavior: https://bugs.php.net/fix.php?id=80590&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80590&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80590&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80590&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80590&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80590&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80590&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80590&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80590&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80590&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80590&r=mysqlcfg

« previous php.bugs (#231371) next »