|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-10-10 13:37 UTC] stuart at horuskol dot net
Description: ------------ This is tested on: PHP 5.3.2-1ubuntu4.5 with Suhosin-Patch (cli) (built: Sep 17 2010 13:49:46) file_info() is reporting a CSS file has having the mimetype 'text/x-c' instead of 'text/css' however, the command line tool 'mimetype' correctly identifies the file using the same library at '/usr/share/misc/magic' the file being tested is available at http://horuskol.net/reset.css Test script: --------------- PHP: $finfo = new finfo(FILEINFO_MIME); var_dump($finfo->file('/path/to/file/reset.css')); $finfo = new finfo(FILEINFO_MIME, '/usr/share/misc/magic'); var_dump($finfo->file('/path/to/file/reset.css')); $finfo = finfo_open(FILEINFO_MIME, '/usr/share/misc/magic'); var_dump(finfo_file($finfo, '/path/to/file/reset.css')); Command Line: mimetype -DM --database /usr/share/misc/magic /path/to/file/reset.css Expected result: ---------------- string(26) "text/css; charset=us-ascii" Actual result: -------------- string(26) "text/x-c; charset=us-ascii" PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 21:00:01 2025 UTC |
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.stepanov@somewhere.com stepan.stepanov@somewhereelse.com +charlotte@server.com herr.totalscheisse@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'); ?>We noticed that this bug is present in php 5.4.10 on windows. We do not have the Suhosin-Patch installed: PHP 5.4.10 (cli) (built: Dec 19 2012 20:33:35) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans We also have the problem when a csv file is uploaded with Seven starting a lineExperienced same problem. PHP 5.5.3-1ubuntu2 (cli) (built: Oct 9 2013 14:49:12) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans Linux 3.11.0-13-generic #20-Ubuntu SMP Wed Oct 23 07:38:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux