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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: alex at buayacorp dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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
 [2023-04-13 21:07 UTC] austin dot barnes04 at gmail dot com
Any movement on this issue? We just ran into this and have a temporary fix in our code base.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 27 16:01:27 2024 UTC