|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57322 mime.magic is misread on lines containing '!'
Submitted: 2006-10-26 04:40 UTC Modified: 2006-11-07 16:22 UTC
From: a at b dot c dot de Assigned:
Status: Not a bug Package: Fileinfo (PECL)
PHP Version: 5.1.6 OS: Windows XP
Private report: No CVE-ID: None
 [2006-10-26 04:40 UTC] a at b dot c dot de
When mime.magic contains a line that specifies a string type magic value, and that magic string starts with an exclamation mark (!) character, the Windows version of fileinfo always regards this as matching the file.

Reproduce code:
The magic.mime database used here is the one shipped with PHP5.1.6; the first line of the "offending" type is 

0	string		!<arch>\ndebian application/x-dpkg

The code and output only returns the first "matching" type; using FILEINFO_CONTINUE shows that all magic strings starting with '!' match whatever the actual file type.

$fh = finfo_open(FILEINFO_NONE, '\php\extras\magic.mime');
// A valid TADS game file (the entry for this is earlier than the above debian package entry)
echo finfo_file($fh, 'c:\tads.gam');
echo "\n";
// A valid PNG image file (the entry for this is later than the above debian package entry)
echo finfo_file($fh, 'c:\image.png');
echo "\n";
// A generic file of no recognised type
echo finfo_file($fh, 'c:\');

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-07 16:22 UTC] ilia at prohost dot org
Sorry, but your problem does not imply a bug in PECL itself.  For a
list of more appropriate places to ask for help using PECL, please
visit as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PECL.

The parsing of the file is done by the fileinfo library not 
PHP, so this would be a bug with the library.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 12:01:33 2024 UTC