Bug #67516 [Opn->Fbk]: wrong mimetypes with finfo_file(filename, FILEINFO_MIME_TYPE)

From: Date: Sun, 11 Jan 2015 17:40:38 +0000
Subject: Bug #67516 [Opn->Fbk]: wrong mimetypes with finfo_file(filename, FILEINFO_MIME_TYPE)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189889@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67516&edit=1

 ID:                 67516
 Updated by:         ab@php.net
 Reported by:        spam2 at rhsoft dot net
 Summary:            wrong mimetypes with finfo_file(filename,
                     FILEINFO_MIME_TYPE)
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Linux
 PHP Version:        5.5.13
 Block user comment: N
 Private report:     N

 New Comment:

Usage of external libmagic isn't possible for various reasons, the patched version is tightly
integrated with PHP. 

@spam2, @fayez, which file/PHP versions was used?

@spam2, please post the image you've an issue with to http://picpaste.com/ . You could probably check with bug #68731
whether it's reproducible for you.

Thanks.


Previous Comments:
------------------------------------------------------------------------
[2014-07-04 13:56:32] spam2 at rhsoft dot net

i know by myself that it works for most files, but this bugtracker lacks capability to attach the
affected file, 

anyways, if php would use systems file-utilities/libraries the behavior of PHP and other
applications would be indetical and it would not need to carry some MB of redundant data

------------------------------------------------------------------------
[2014-07-04 13:53:03] fayez at bem981 dot cu dot cc

i tried this example with gif image size:8.2m
and i get this result:
/usr/bin/file -b --mime-type
image/gif

finfo_file(filename, FILEINFO_MIME_TYPE)
image/gif
it's work

------------------------------------------------------------------------
[2014-06-29 14:57:44] spam2 at rhsoft dot net

what i completly don't understand is why PHP obviously brings it's on mime-magic and
static implementation instead just use the operating systems file-libs

------------------------------------------------------------------------
[2014-06-25 17:00:19] spam2 at rhsoft dot net

Description:
------------
i have at least one GIF image with 2.3 MB which is detected as application/octet-stream while
'/usr/bin/file -b --mime-type' on the same machine correctly results in image/gif

sadly i don't see here any option to attach the image :-(
that makes it hard to implement relieable checks if the
extension of uploads matchs the expected mime-type

[harry@srv-rhsoft:~/Desktop]$ php mime.php 
/usr/bin/file -b --mime-type
image/gif

finfo_file(filename, FILEINFO_MIME_TYPE)
application/octet-stream


Test script:
---------------
#!/usr/bin/php
<?php
 echo '/usr/bin/file -b --mime-type' . "\n";
 passthru('/usr/bin/file -b --mime-type ' . escapeshellarg(__DIR__ . '/1.gif'));
 echo "\n";
 echo 'finfo_file(filename, FILEINFO_MIME_TYPE)' . "\n";
 $finfo_handle = finfo_open();
 echo finfo_file($finfo_handle, __DIR__ . '/1.gif', FILEINFO_MIME_TYPE) . "\n";
 finfo_close($finfo_handle);
?>

Expected result:
----------------
image/gif as result

Actual result:
--------------
application/octet-stream as result


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=67516&edit=1


Thread (30 messages)

« previous php.bugs (#189889) next »