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

martin k. commented on TIKA-4172:
---------------------------------

Hey [~tilman], I did read over the docs, and I should have stated this. Later 
in the document (well, I read version 2.9.1), under "The default Mime Types 
Detector" it also says:

{quote}Firstly, magic based detection is used on the start of the file. … Next, 
if available, the filename (from TikaCoreProperties.RESOURCE_NAME_KEY) is then 
used to improve the detail of the detection, such as when magic detects a text 
file, and the filename hints it's really a CSV. Finally, if available, the 
supplied content type (from Metadata.CONTENT_TYPE) is used to further refine 
the type.{quote}

This suggests that the filename is only used to refine the detection. However, 
in the case I highlighted, the content-based detection would have detected a 
binary file ({{application/octet-stream}}), which then gets overruled by the 
filename-based "refinement" into a {{text/*}} content type, and I think this 
shouldn't be.

> Apple binary file incorrectly identified as text/x-sql due to filename
> ----------------------------------------------------------------------
>
>                 Key: TIKA-4172
>                 URL: https://issues.apache.org/jira/browse/TIKA-4172
>             Project: Tika
>          Issue Type: Bug
>          Components: general
>    Affects Versions: 2.9.1
>            Reporter: martin k.
>            Priority: Minor
>
> This is related to [https://github.com/eikek/docspell/issues/2376] and 
> [https://github.com/eikek/docspell/issues/2403.]
> Take the following Base64 encoding of a binary Apple-generated file. No idea 
> what it does. You can get the file by piping the following to e.g. {{base64 
> -d > something.sql}}
> {code:java}
> ABRkMDEwMWM2Nl9teVNRTDQwLnNxbAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbUJJTgAA
> AAAAAAAAAAAAAAAAAACCgf+/AAA=
> {code}
> If this file is name {{{}something.sql{}}}, then Tika will classify it as 
> {{{}text/x-sql{}}}, which it is not. It seems like more weight is given to 
> the filename (extension) than the fact that the file is binary anyway.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to