Bug #79764 [Com]: finfo::file returns text/plain mime type when JSON contains empty arrays
| From: | mamontovdmitriy at mail dot ru | Date: | Wed, 01 Jul 2020 12:48:48 +0000 |
| Subject: | Bug #79764 [Com]: finfo::file returns text/plain mime type when JSON contains empty arrays | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227757@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79764&edit=1
ID: 79764
Comment by: mamontovdmitriy at mail dot ru
Reported by: edi dot modric at gmail dot com
Summary: finfo::file returns text/plain mime type when JSON
contains empty arrays
Status: Open
Type: Bug
Package: Filesystem function related
Operating System: Ubuntu 20.04
PHP Version: 7.4.7
Block user comment: N
Private report: N
New Comment:
I confirm this issue.
Previous Comments:
------------------------------------------------------------------------
[2020-07-01 12:26:33] edi dot modric at gmail dot com
Description:
------------
Using the following JSON document:
{
"foo": []
}
finfo::file method wrongly returns text/plain as mime type instead of application/json.
Modifying the JSON document to e.g.:
{
"foo": ["bar"]
}
makes the function behave correctly and returns application/json.
Test script:
---------------
<?php
$finfo = new finfo(FILEINFO_MIME_TYPE);
echo $finfo->file('file.json') . PHP_EOL;
Expected result:
----------------
With the following content of file.json:
{
"foo": []
}
I expect to see "application/json" as the output.
Actual result:
--------------
With the following content of file.json:
{
"foo": []
}
"text/plain" is returned.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79764&edit=1