Edit report at https://bugs.php.net/bug.php?id=53035&edit=1
ID: 53035
Comment by: stepan dot stepanov at gmail dot com
Reported by: stuart at horuskol dot net
Summary: finfo_file() returns incorrect mimetype
Status: No Feedback
Type: Bug
Package: Filesystem function related
Operating System: Linux/Ubuntu 10.04
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Command line "file" programm shows the right result. Though php reports wrong
one.
CentOS release 5.8
See details below:
$ file -i char2.csv
char2.csv: text/plain; charset=us-ascii
$ file -i char.csv
char.csv: text/plain; charset=us-ascii
$ php -f mimetest.php
char2.csv: text/plain
char.cvs: text/x-c
$ diff -u char2.csv char.csv
--- char2.csv 2012-10-10 15:07:05.000000000 +0200
+++ char.csv 2013-02-25 15:47:38.000000000 +0100
@@ -1,3 +1,4 @@
stepan.stepa...@somewhere.com
stepan.stepa...@somewhereelse.com
+charlo...@server.com
herr.totalschei...@mime.typ
----------------------------------------------------------
$ php -v
PHP 5.3.19 (cli) (built: Nov 25 2012 13:17:45)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.1.3, Copyright (c) 2002-2012, by Derick Rethans
$ cat mimetest.php
<?
$finfo = new finfo(FILEINFO_MIME_TYPE);
echo "\nchar2.csv: ".$finfo->file('char2.csv');
echo "\nchar.cvs: ".$finfo->file('char.csv');
?>
Previous Comments:
------------------------------------------------------------------------
[2013-02-18 00:34:31] 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 "Open". Thank you.
------------------------------------------------------------------------
[2013-01-17 23:03:53] a dot lecca at gmail dot com
On PHP 5.3.18
Keven will also trigger a text/x-asm mime type
Also, confirming the Charlotte issue
------------------------------------------------------------------------
[2012-11-29 14:34:54] stepan dot stepanov at gmail dot com
The problem still exists (PHP 5.3.19)
If i have csv file with names (e.g.) it is recognised as text/plan (that is
expected)
But when i have someone called 'charles' or 'charlotte' inside - my file is
recognised as text/x-c (obviously dues to word 'char')
------------------------------------------------------------------------
[2012-09-30 17:13:01] paj...@php.net
Please try using this snapshot:
http://snaps.php.net/php5.3-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
------------------------------------------------------------------------
[2012-09-29 11:00:33] DonJaime at donjaime dot de
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.
------------------------------------------------------------------------
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