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

 ID:                 55182
 Comment by:         narf at bofh dot bg
 Reported by:        dominique at ramaekers-stassart dot be
 Summary:            finfo_file() doesn't detect right mime-type
 Status:             Open
 Type:               Bug
 Package:            Unknown/Other Function
 Operating System:   Ubuntu 10.04
 PHP Version:        5.3SVN-2011-07-11 (SVN)
 Block user comment: N
 Private report:     N

 New Comment:

AFAIK, this is depends on the OS and external packages. MIME type detection 
isn't a problem just for PHP and I doubt there's much that can be done about it.


Previous Comments:
------------------------------------------------------------------------
[2012-08-14 19:58:38] tom at tombartling dot com

This also fails to detect the correct mime-type for PHP files. If the file 
starts with <?php, it returns text/x-php as the mime-type. If the file starts 
with <!DOCTYPE html><html>... and the PHP code is anywhere else in the file, it 
returns text/html as the mime-type.

It fails to detect a CSV file correctly. 

This is a problem for the CodeIgniter framework, since it's file upload class 
uses this function.

I'm on Red Hat Enterprise Linux Server release 5.8 (Tikanga).

------------------------------------------------------------------------
[2011-07-11 16:33:30] dominique at ramaekers-stassart dot be

Description:
------------
The finfo_file command detects openxml documents (xlsb, xlsx,...) as 
application/zip files.

Can this be fixed?

There are a lot of people who have to hack the mediawiki code to allow these 
files for upload. With these hacks they lose a part of there security: the 
checking of the finfo_file-mime-type against the file extension itself...


Test script:
---------------
php > $finfo = finfo_open(FILEINFO_MIME_TYPE);
php > echo finfo_file($finfo, '/mnt/Transfert/test.xlsb');
application/zip






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



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

Reply via email to