php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55182 finfo_file() doesn't detect right mime-type
Submitted: 2011-07-11 16:33 UTC Modified: 2016-12-04 04:22 UTC
Votes:9
Avg. Score:4.3 ± 0.8
Reproduced:9 of 9 (100.0%)
Same Version:2 (22.2%)
Same OS:2 (22.2%)
From: dominique at ramaekers-stassart dot be Assigned:
Status: No Feedback Package: Unknown/Other Function
PHP Version: 5.3SVN-2011-07-11 (SVN) OS: Ubuntu 10.04
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dominique at ramaekers-stassart dot be
New email:
PHP Version: OS:

 

 [2011-07-11 16:33 UTC] 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





Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-14 19:58 UTC] 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).
 [2012-08-15 15:04 UTC] narf at bofh dot bg
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.
 [2016-11-24 16:02 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2016-11-24 16:02 UTC] ab@php.net
Thanks for the report. The concrete file is needed in this case.

Thanks.
 [2016-12-04 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 19 02:01:29 2024 UTC