php.net |  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: a at b dot c dot de
New email:
PHP Version: OS:

 

 [2006-10-26 04:40 UTC] a at b dot c dot de
Description:
------------
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.

<?php
$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:\bogus.foo');
?>

Expected result:
----------------
application/x-tads-game
image/x-png
data


Actual result:
--------------
application/x-tads-game
application/x-dpkg
application/x-dpkg


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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 http://pecl.php.net/support/ 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-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 17 13:03:37 2021 UTC