|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-05-11 15:21 UTC] 209721949 at qq dot com
Description: ------------ i use finfo_file to get the apk file mime type, but it always return application/zip but not application/vnd.android Test script: --------------- $finfo = finfo_open(FILEINFO_MIME_TYPE); extension $filename="xxx.apk"; echo finfo_file($finfo, $filename); finfo_close($finfo); Expected result: ---------------- i'm not sure if it's a bug, i just want to get the right result. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 15:00:01 2025 UTC |
just tested it again with PHP 7.1.5 "/usr/bin/php ext/fileinfo/create_data_file.php /usr/share/misc/magic.mgc > ext/fileinfo/data_file.c" *only seems* to work happily i included a large testsuite in our pgo-build and stop rpmbuild when it fails, no need for complete gcc-profiling and second buildstage when the result is a broken PHP, see below ________________________________________________________ frankly as i reported the bug i waited at least 2 years in the hope fileinfo get any updates, nothing.... so we have for at least 4 years a known image/gif detected as application/octet-stream which makes any verification of useruploads pointless when you need to allow "application/octet-stream" you case with "zip" is harmless, at least you can distinct it form a random executable :-) [harry@srv-rhsoft:/data/lounge-daten/php-mimtype-bug]$ php mime.php /mnt/data/lounge-daten/php-mimtype-bug/1.gif /usr/bin/file -b --mime-type image/gif finfo_file(filename, FILEINFO_MIME_TYPE) application/octet-stream ________________________________________________________ FAILED: NOT ALL TESTS PASSED [11-May-2017 17:31:22 Europe/Vienna] PHP Warning: finfo_open(): Failed to load magic database at '(null)'. in /Volumes/dune/www-servers/cms/cms/autotests/api_captcha.php on line 39 [11-May-2017 17:31:22 Europe/Vienna] CMS-AUTOTEST: cl_api->captcha->test() failed - TypeError: finfo_file() expects parameter 1 to be resource, boolean given in /Volumes/dune/www-servers/cms/cms/autotests/api_captcha.php:40 Stack trace: #0 /Volumes/dune/www-servers/cms/cms/autotests/api_captcha.php(40): finfo_file(false, '/Volumes/dune/w...', 16) #1 /Volumes/dune/www-servers/cms/cms/api_captcha.php(117): require('/Volumes/dune/w...') #2 /Volumes/dune/www-servers/cms/cms/autotest.php(457): cl_captcha->test() #3 {main} [11-May-2017 17:31:25 Europe/Vienna] PHP Warning: finfo_open(): Failed to load magic database at '(null)'. in /Volumes/dune/www-servers/phpincludes/global_rh_misc.inc.php on line 3407 [11-May-2017 17:31:25 Europe/Vienna] PHP Warning: finfo_open(): Failed to load magic database at '(null)'. in /Volumes/dune/www-servers/phpincludes/global_rh_misc.inc.php on line 3407 [11-May-2017 17:31:25 Europe/Vienna] PHP Warning: finfo_open(): Failed to load magic database at '(null)'. in /Volumes/dune/www-servers/phpincludes/global_rh_misc.inc.php on line 3407requinix@php.net: do you really think it's a soapbox when i had to implement passthru("/usr/bin/file -b --mime-type $file") wrapped in output-buffers on several places years ago beause the php implementation is unrelieable, outdated und can't distinct in known cases between a executeable and a image while the file command can?