Bug #78183 [Com]: finfo_file shows wrong mime-type for .tga file

From: Date: Fri, 21 Jun 2019 13:10:23 +0000
Subject: Bug #78183 [Com]: finfo_file shows wrong mime-type for .tga file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221436@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78183&edit=1 ID: 78183 Comment by: dev at jdoubleu dot de Reported by: dev at jdoubleu dot de Summary: finfo_file shows wrong mime-type for .tga file Status: Feedback Type: Bug Package: Filesystem function related Operating System: Linux PHP Version: 7.2.19 Block user comment: N Private report: N New Comment: I have uploaded the images to Docker Hub: https://hub.docker.com/r/jdoubleu/php-bug-78183 Running the script in Travis CI also confirms this bug: https://travis-ci.com/jdoubleu/php-bug-78183/builds/116430262#L236 Previous Comments: ------------------------------------------------------------------------ [2019-06-21 06:28:01] krakjoe@php.net Ah, I still had this page open from yesterday, and saw your comment after I posted analysis. I'll take another look ... ------------------------------------------------------------------------ [2019-06-21 06:25:39] krakjoe@php.net I cannot reproduce this error, in addition, our use of the underlying API (magic_stream) doesn't seem to allow us to cause this, the only thing I can think of is that maybe the magic database is somehow corrupted, but this seems highly unlikely. Running the script as it was is not possible from my location, and so probably the same is true for others. I suggest you upload the image to a globally accessible location, and suggest you expand the test script to include buffer (string) and stream (resource) usages. ------------------------------------------------------------------------ [2019-06-19 16:29:46] dev at jdoubleu dot de I created a repository on github which tests this bug against PHP 7.2, 7.3 and 7.3RC1 inside docker containers: https://github.com/jdoubleu/php-bug-78183 The issue only affects PHP 7.2 ------------------------------------------------------------------------ [2019-06-19 15:51:03] dev at jdoubleu dot de Description: ------------ The finfo_file() method does not return the correct mime-type for .tga files. Test script: --------------- ini_set('user_agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36'); $src = fopen('http://people.math.sc.edu/Burkardt/data/tga/earth.tga', 'r'); $dest = fopen('image.tga', 'w'); stream_copy_to_stream($src, $dest); print(finfo_file(finfo_open(FILEINFO_MIME_TYPE), 'image.tga')); // => image/x-tgaimage/x-tga Expected result: ---------------- "image/x-tga" Actual result: -------------- "image/x-tgaimage/x-tga" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78183&edit=1

« previous php.bugs (#221436) next »