Bug #79764 [Com]: finfo::file returns text/plain mime type when JSON contains empty arrays
| From: | edi dot modric at gmail dot com | Date: | Wed, 01 Jul 2020 13:39:08 +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-227760@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: edi dot modric at gmail dot com
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:
eddie@abyss ~ $ file a.json
a.json: ASCII text
eddie@abyss ~ $ file b.json
b.json: JSON data
So it seems this might not be a PHP issue, but a system one. If so, feel free to close this and
sorry for the noise.
Previous Comments:
------------------------------------------------------------------------
[2020-07-01 13:31:28] cmb@php.net
What does
file report about that file?
------------------------------------------------------------------------
[2020-07-01 12:48:48] mamontovdmitriy at mail dot ru
I confirm this issue.
------------------------------------------------------------------------
[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