[ 
https://issues.apache.org/jira/browse/TIKA-5067?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18154387#comment-18154387
 ] 

ASF GitHub Bot commented on TIKA-5067:
--------------------------------------

subbudvk commented on PR #3708:
URL: https://github.com/apache/tika/pull/3708#issuecomment-7367200129

    Thanks @tballison  I had looked at this in 
https://github.com/apache/tika/pull/3705. If I read it right, with 
DefaultDetector on this branch a file named a.txt containing 
{"a":"<html><body>x</body></html>","b":1} is detected as               
     application/json, where it was text/plain before. The same seems to happen 
for .js and .csv files. Is this intended? I was thinking the JSON result could 
apply only when the name is .json, unknown or absent, so a known non-JSON name 
is left
     alone. I'm happy to go with your approach if you prefer it. 




>  JSON with an HTML tag inside a string value is detected as text/html
> ---------------------------------------------------------------------
>
>                 Key: TIKA-5067
>                 URL: https://issues.apache.org/jira/browse/TIKA-5067
>             Project: Tika
>          Issue Type: Bug
>          Components: detector
>            Reporter: Subbu
>            Priority: Major
>         Attachments: findings.json
>
>
> Tika has no JSON magic or detector. The <html magic matches anywhere in the 
> first 8 KB of text, so a valid JSON document with an HTML tag inside a string 
> value is reported as text/html. This happens even when the file is named 
> *.json
> *Steps to reproduce:* 
> 1) Check attached json 
> 2) Run detect with the attached json. 
> *Actual:* text/html                                                           
>                                                                     
> *Expected:* application/json 
> *Fix options*
> I see two ways to fix this: (A) a content-only JSON magic rule in 
> tika-mimetypes.xml, which is small but can't see the extension and would also 
> turn .txt, .csv and .js files that start like JSON into application/json, or
> (B) a strict JSON check in MimeTypes.detect that overrides only a weak 
> text/html or text/plain verdict and respects the name and Content-Type hints. 
>                                                                               
>                                  
> Which approach do you prefer, or would you suggest another?
>  



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to