View Issue Details

IDProjectCategoryView StatusLast Update
0000023file[All Projects] Generalpublic2018-10-08 18:26
Reportervitalyisaev2Assigned Tochristos 
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Product Version5.34 
Target VersionFixed in Version5.35 
Summary0000023: JSON is determined as "text/plain"
DescriptionHello!
I think that JSON files should have "application/json" content-type according to RFC4627 (http://www.ietf.org/rfc/rfc4627.txt)

Kind regards,
Vitaly

Steps To Reproduce[root@9826ba54a40a /]# cat /tmp/ololo.json
{
    "abc": "edf",
    "json": "crab",
    "ololo": [
        1,
        2,
        3
    ],
    "subcrab": {
        "name": "crab",
        "surname": "subcrab"
    }
}

[root@9826ba54a40a /]# file --version
file-5.34
magic file from /etc/magic:/usr/share/misc/magic
[root@9826ba54a40a /]# file --mime-type /tmp/ololo.json
/tmp/ololo.json: text/plain
TagsNo tags attached.
Attach Tags

Activities

vitalyisaev2

2018-07-30 15:38

reporter  

ololo.json (144 bytes)

christos

2018-08-03 09:15

manager   ~0000040

Yes, but that would require something in file to be able to parse json (so that it can determine if it is json)... What about a json file that has a syntax error? Should it be recognized as json?

anonymous

2018-08-08 06:55

reporter   ~0000042

Hi! I suppose that we should recognize it as json in all cases when it's possible. Even it has a syntax error. Of course this behaviour depends on json parser.

vitalyisaev2

2018-08-08 07:43

reporter   ~0000043

Perhaps libmagic could use some lightweight library that will just validate JSON (without building whole deserialized object in memory)...

I'm not sure if we are able to distinguish JSON with syntax error and arbitrary text file. From my point of view, falling back to "text/plain" with broken JSON would be a better option.

christos

2018-08-11 11:06

manager   ~0000044

Fixed on HEAD.

vitalyisaev2

2018-08-13 10:51

reporter   ~0000050

Thank you, going to check it in a couple of days

vitalyisaev2

2018-10-08 14:24

reporter   ~0000092

Sorry for the delay with response, I've checked it, works good. I think we can close this issue.

christos

2018-10-08 18:26

manager   ~0000094

Submitter verified it is fixed.

Issue History

Date Modified Username Field Change
2018-07-30 15:38 vitalyisaev2 New Issue
2018-07-30 15:38 vitalyisaev2 File Added: ololo.json
2018-08-03 09:14 christos Assigned To => christos
2018-08-03 09:14 christos Status new => assigned
2018-08-03 09:15 christos Status assigned => feedback
2018-08-03 09:15 christos Note Added: 0000040
2018-08-08 06:55 anonymous Note Added: 0000042
2018-08-08 07:43 vitalyisaev2 Note Added: 0000043
2018-08-08 07:43 vitalyisaev2 Status feedback => assigned
2018-08-11 11:06 christos Status assigned => feedback
2018-08-11 11:06 christos Note Added: 0000044
2018-08-13 10:51 vitalyisaev2 Note Added: 0000050
2018-08-13 10:51 vitalyisaev2 Status feedback => assigned
2018-10-08 14:24 vitalyisaev2 Note Added: 0000092
2018-10-08 18:26 christos Status assigned => resolved
2018-10-08 18:26 christos Resolution open => fixed
2018-10-08 18:26 christos Fixed in Version => 5.35
2018-10-08 18:26 christos Note Added: 0000094