Bug #55691 [Opn->Fbk]: different results from finfo_file and finfo_buffer
Edit report at https://bugs.php.net/bug.php?id=55691&edit=1
ID: 55691
Updated by: cmb@php.net
Reported by: di_herbert dot huber at yahoo dot com
Summary: different results from finfo_file and finfo_buffer
-Status: Open
+Status: Feedback
Type: Bug
-Package: Unknown/Other Function
+Package: Filesystem function related
Operating System: WinXP HE SP2
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
Previous Comments:
------------------------------------------------------------------------
[2011-09-17 07:44:26] thomas at partyflock dot nl
Happens to me too, and I experience this for an xls/Excel document too.
------------------------------------------------------------------------
[2011-09-14 09:35:36] di_herbert dot huber at yahoo dot com
Description:
------------
different results from finfo_file and finfo_buffer
Scenario:
1. MS Excel-File stored in mySQL database LONGBLOB-Column
2. This binary data selected from database
3. This binary data stored to tempfile
4. mime-type sniffing done by finfo_buffer on binary data
> result: application/octet-stream
5. mime-type sniffing done by finfo_file on tempfile
> result: application/vnd.ms-excel
PROBLEM:
different result, dependent on used Fileinfo Function
Comment: The tempfile has NO extension like ".xls" that could be used as
hint for mimetype-sniffing
Test script:
---------------
<?PHP
...
$tempFileName = tempnam(sys_get_temp_dir(), "tempfile");
$tempFileHandle = fopen($tempFileName, "w");
fwrite($tempFileHandle, $attrib);
fclose($tempFileHandle);
// ensure that "extension=php_fileinfo.dll" is enabled in php.ini
$finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala
mimetype extension
$fileContentsTypeBuf = finfo_buffer($finfo, $attrib,
FILEINFO_MIME_TYPE);
$fileContentsType = finfo_file($finfo, $tempFileName);
finfo_close($finfo);
...
Expected result:
----------------
same result
"application/vnd.ms-excel" from finfo_buffer
"application/vnd.ms-excel" from finfo_file
Actual result:
--------------
different results
"application/octet-stream" from finfo_buffer
"application/vnd.ms-excel" from finfo_file
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55691&edit=1
Thread (7 messages)