[ 
https://issues.apache.org/jira/browse/TIKA-5067?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Subbu updated TIKA-5067:
------------------------
    Description: 
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?

 

  was:
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?

 


>  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