From: Operating system: WinXP HE SP2 PHP version: 5.3.8 Package: Unknown/Other Function Bug Type: Bug Bug description:different results from finfo_file and finfo_buffer
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 bug report at https://bugs.php.net/bug.php?id=55691&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55691&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55691&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55691&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=55691&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55691&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=55691&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=55691&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=55691&r=needscript Try newer version: https://bugs.php.net/fix.php?id=55691&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=55691&r=support Expected behavior: https://bugs.php.net/fix.php?id=55691&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=55691&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=55691&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=55691&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55691&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=55691&r=dst IIS Stability: https://bugs.php.net/fix.php?id=55691&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=55691&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=55691&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=55691&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=55691&r=mysqlcfg