|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75887 mime type detection problem
Submitted: 2018-01-29 21:21 UTC Modified: 2018-01-30 16:18 UTC
From: tunderzone at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 7.1.13 OS:
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:
Bug Type:
From: tunderzone at gmail dot com
New email:
PHP Version: OS:


 [2018-01-29 21:21 UTC] tunderzone at gmail dot com
having ".text" as first characters on any line of a css file will result in mime being resolved as text/x-asm.

Test script:
$info = finfo_open(FILEINFO_MIME_TYPE);
$tipe = finfo_buffer($info, '.text {color: #CCCCCC;}');

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-29 23:29 UTC]
-Status: Open +Status: Not a bug
 [2018-01-29 23:29 UTC]
MIME detection works by examining the first few bytes of a file (or input stream). It is not perfect.
 [2018-01-30 11:37 UTC] tunderzone at gmail dot com
the text that cause this is not on first line nor last. it is somewhere in the middle of the file. the file size is 14K.
running finfo_open and finfo_file on that file in php 5.5.38 yields text/plain but in php7.1.13 yields text/x-asm
something has changed from php 5 to php 7. this is why i posted this bug.
 [2018-01-30 16:18 UTC]
PHP's bundled information comes from the libmagic library, which has a rule that says to scan lines for ".text" and mark the content as text/x-asm if found.

So the bundled magic database isn't working for you. Try with your system's - probably /usr/share/misc/magic.
  $info = finfo_open(FILEINFO_MIME_TYPE, "/usr/share/misc/magic");
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon May 17 05:01:24 2021 UTC