php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78028 finfo_file reports duplicate mime type for some `docx` files
Submitted: 2019-05-17 13:39 UTC Modified: 2019-05-17 14:09 UTC
From: alex at buayacorp dot com Assigned: cmb (profile)
Status: Duplicate Package: Filesystem function related
PHP Version: 7.3.5 OS: Debian Jessie
Private report: No CVE-ID: None
 [2019-05-17 13:39 UTC] alex at buayacorp dot com
Description:
------------
While migrating our application from PHP 7.2 to PHP 7.3, we noticed that some `docx` files report a duplicate mime type. It looks like the fix committed in https://github.com/php/php-src/commit/d874d4a15c2e17a753d580691906c95e9153b823 is the one that introduces this issue, previous commits don't expose this issue.

The below builds are compiled with: ./configure --disable-all --enable-fileinfo && make
Switched to a new branch 'ee50461'
./sapi/cli/php ../payload.php
application/vnd.openxmlformats-officedocument.wordprocessingml.document

Switched to a new branch 'd874d4a'
./sapi/cli/php ../payload.php
application/vnd.openxmlformats-officedocument.wordprocessingml.documentapplication/vnd.openxmlformats-officedocument.wordprocessingml.document

Test script:
---------------
<?php
// You can grab a copy of this file in https://www.buayacorp.com/demo.docx (it's an empty Google doc file saved as "docx" format).
$filename = __DIR__ . '/demo.docx';
$finfo = finfo_open(FILEINFO_MIME_TYPE);
echo finfo_file($finfo, $filename).PHP_EOL;
finfo_close($finfo);

Expected result:
----------------
application/vnd.openxmlformats-officedocument.wordprocessingml.document

Actual result:
--------------
application/vnd.openxmlformats-officedocument.wordprocessingml.documentapplication/vnd.openxmlformats-officedocument.wordprocessingml.document

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-17 14:05 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2019-05-17 14:05 UTC] cmb@php.net
This is basically a duplicate of bug #77784.
 [2019-05-17 14:08 UTC] sjon@php.net
-Status: Duplicate +Status: Verified -Assigned To: cmb +Assigned To:
 [2019-05-17 14:08 UTC] sjon@php.net
confirmed, see https://3v4l.org/nVN7h - this has been happening since 7.3.2
 [2019-05-17 14:09 UTC] sjon@php.net
-Status: Verified +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2019-05-17 14:09 UTC] sjon@php.net
oops, redupping
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jan 27 10:01:24 2020 UTC