php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73006 String is recognized as zlib
Submitted: 2016-09-02 19:08 UTC Modified: 2016-09-02 20:28 UTC
From: rasi at xssn dot at Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 7.0.10 OS: Arch Linux 64bit
Private report: No CVE-ID: None
 [2016-09-02 19:08 UTC] rasi at xssn dot at
Description:
------------
The string "(Singer/Songwriter) Andrea Schroeder                   Void" is reported as zlib mimetype by php.

Test script:
---------------
save above string in a file and use the following script to identify mimetype with php:

<?php

function mimetype($file) {
	$fileinfo = new finfo(FILEINFO_MIME_TYPE);
	$mimetype = $fileinfo->file($file);
	return $mimetype;
}

echo mimetype($argv[1]);


Expected result:
----------------
I expect mimetype text/plain

Actual result:
--------------
Actual result is application/zlib

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-02 19:19 UTC] rasi at xssn dot at
It's actually the "(S" at the start of the string that triggers this
 [2016-09-02 20:28 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: *General Issues +Package: Filesystem function related
 [2016-09-02 20:28 UTC] requinix@php.net
"(S" 0x2853 are magic bytes for application/zlib data. We can't change that.

MIME typing is great and all but generally works best with binary files. Sometimes you should rely on file extensions instead.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Aug 09 17:01:23 2020 UTC