php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68916 Mime Type for some jpeg files not detected correctly
Submitted: 2015-01-26 14:04 UTC Modified: 2020-11-29 04:22 UTC
From: uwej711 at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: Filesystem function related
PHP Version: 5.5.9 OS: Ubuntu 14.04
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
3 + 25 = ?
Subscribe to this entry?

 
 [2015-01-26 14:04 UTC] uwej711 at gmail dot com
Description:
------------
There are some jpegs that are detected as Linux/i386 core file. This is only fixed in libmagic 5.18, currently php uses 5.17. See https://github.com/file/file/commit/7e21b5477712cedf70403624d705c6cd7656a780for the change in libmagic. 

There is currently no way to work around this as the magic file is compiled into php


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-26 14:07 UTC] uwej711 at gmail dot com
-Summary: Mime Types for jpeg files not detected correctly +Summary: Mime Type for some jpeg files not detected correctly -PHP Version: 5.5.21 +PHP Version: 5.5.9
 [2015-01-26 14:07 UTC] uwej711 at gmail dot com
Sorry this is the correct patch link:

https://github.com/file/file/commit/7e21b5477712cedf70403624d705c6cd7656a780

This bug also affects the latest 5.6.5 version
 [2015-01-27 08:24 UTC] uwej711 at gmail dot com
to reproduce:

<?php
$finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
echo finfo_file($finfo, 'test.jpg') . "\n";
finfo_close($finfo);
?>

and the jpeg from 

https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=TESTp.jpg;att=1;bug=657545
 [2020-11-18 15:53 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-11-18 15:53 UTC] cmb@php.net
> There is currently no way to work around this as the magic file
> is compiled into php

libmagic is compiled into PHP, but not the magic file.

> This is only fixed in libmagic 5.18, […]

So this should be fixed for any of the actively supported PHP
versions[1].

[1] <https://www.php.net/supported-versions.php>
 [2020-11-18 16:23 UTC] rtrtrtrtrt at dfdfdfdf dot dfd
> libmagic is compiled into PHP, but not the magic file

this is not true at all!

with some luck (systems magic and the bundeled compatible) you can even re-generate the responsible file with "php -d 'display_errors=0' ext/fileinfo/create_data_file.php /usr/share/misc/magic.mgc > ext/fileinfo/data_file.c" at build time
 [2020-11-29 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 04:01:30 2024 UTC