Bug #53035 [Com]: finfo_file() returns incorrect mimetype

From: Date: Sat, 29 Sep 2012 11:00:33 +0000
Subject: Bug #53035 [Com]: finfo_file() returns incorrect mimetype
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-173798@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=53035&edit=1

 ID:                 53035
 Comment by:         DonJaime at donjaime dot de
 Reported by:        stuart at horuskol dot net
 Summary:            finfo_file() returns incorrect mimetype
 Status:             Not a bug
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   Linux/Ubuntu 10.04
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

This problem occurs with no comment at the start of the file, too.

Rather than giving up because "other programs using the same magic database are resulting in
the same file being detected as C source" it might be worth putting in the extra few lines of
code required to return the right mime type on the basis of the file extension, if it exists.
Worldwide, this would save a lot of energy and frustration.


Previous Comments:
------------------------------------------------------------------------
[2011-12-12 12:08:56] n dot delargy at ctidigital dot com

It may also be worth noting that the file was converted from an excel sheet to a text tab delimited
and charset was us-ascii

------------------------------------------------------------------------
[2011-12-12 12:06:42] n dot delargy at ctidigital dot com

I've also had this issue, using ZF Zend_Validate_File_MimeType a text/plain file (according to
file -i /path/to/file.txt) is incorrectly identified as text/x-c in ubuntu 11.10

------------------------------------------------------------------------
[2011-07-06 19:27:16] shawn at thesignchef dot com

I am having the same issue still. Has this been fixed or is there a workaround. Thanks so much.

------------------------------------------------------------------------
[2010-11-09 16:57:47] stephane at emark dot nl

Hi, I just want to say that I experience the same problem.

As felipe@php.net mentionned, if you have any type of comments at the top of your 
file, the problem occurs. 
For example, if i try to get the mime type of a js file with comments at the top, 
it returns "text/x-c", if i remove the comments, then it returns "text/plain", 
which in and of itself is not correct as it should return 'text/javascript'.

Any idea how to circumvent this problem other than removing all my comments ?!?!

------------------------------------------------------------------------
[2010-10-13 00:38:01] stuart at horuskol dot net

"however, the command line tool 'mimetype' correctly identifies the file using the
same library at '/usr/share/misc/magic'"

I tested using the -M switch (as in my example/test script):

mimetype -DM --database /usr/share/misc/magic /path/to/file/reset.css

and this tells me the file is text/css on my platform - are you sure you're using the same
magic database?

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=53035


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


Thread (23 messages)

« previous php.bugs (#173798) next »