Bug #78028 [NEW]: finfo_file reports duplicate mime type for some `docx` files
| From: | alex at buayacorp dot com | Date: | Fri, 17 May 2019 13:39:34 +0000 |
| Subject: | Bug #78028 [NEW]: finfo_file reports duplicate mime type for some `docx` files | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-220883@lists.php.net to get a copy of this message | ||
From: alex at buayacorp dot com
Operating system: Debian Jessie
PHP version: 7.3.5
Package: Filesystem function related
Bug Type: Bug
Bug description:finfo_file reports duplicate mime type for some
docx files
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
--
Edit bug report at https://bugs.php.net/bug.php?id=78028&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=78028&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=78028&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=78028&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=78028&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78028&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78028&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78028&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78028&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78028&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78028&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78028&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78028&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78028&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=78028&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=78028&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78028&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78028&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78028&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78028&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78028&r=mysqlcfg