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

 ID:                 53035
 Comment by:         n dot delargy at ctidigital dot com
 Reported by:        stuart at horuskol dot net
 Summary:            finfo_file() returns incorrect mimetype
 Status:             Bogus
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   Linux/Ubuntu 10.04
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[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 fel...@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?

------------------------------------------------------------------------
[2010-10-12 07:52:11] ahar...@php.net

I get the same result from the command line "file" program on Ubuntu 10.10:

$ curl -s http://horuskol.net/reset.css | file --mime-type -
/dev/stdin: text/x-c

mimetype also believes it's C source:

$ mimetype -DM reset.css 
> Data dirs are: /home/aharvey/.local/share, /usr/share/gnome, 
> /usr/local/share, /usr/share
> Checking all magic rules
> Value "/*" at offset 2 matches at /usr/share/mime/magic line 1136
reset.css: text/x-csrc

The only way I can get mimetype to return text/css is if it also looks at the 
extension (ie is called without -M).

I can't really see any way this is a PHP bug, given other programs using the 
same magic database are resulting in the same file being detected as C source. 
Closing.

------------------------------------------------------------------------
[2010-10-11 15:39:35] fel...@php.net

Strange... It's caused by the comment in the begin of the CSS file.

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


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

Reply via email to