Bug 423251

Summary: kmimetypefinder5 misidentifies some text files as image/x-quicktime
Product: [Plasma] kde-cli-tools Reporter: Nathaniel Beaver <nathanielmbeaver>
Component: generalAssignee: Aleix Pol <aleixpol>
Status: RESOLVED UPSTREAM    
Severity: minor    
Priority: NOR    
Version First Reported In: 5.12.8   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: File that replicates the bug.

Description Nathaniel Beaver 2020-06-19 23:41:57 UTC
SUMMARY

kmimetypefinder5 misidentifies text files as image/x-quicktime if they match 'head -n 1 | grep '^....idat'.

STEPS TO REPRODUCE

1. Create a file called readme.txt that contains only the word "candidate".
2. Run "kmimetypefinder5 readme.txt"

OBSERVED RESULT

image/x-quicktime

EXPECTED RESULT

text/plain

SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.12.9
KDE Frameworks Version: 5.44.0
Qt Version: 5.9.5
Kernel Version: 5.3.0-59-generic

ADDITIONAL INFORMATION

This is due to the magic value of qtif files:

    <magic priority="50">
      <match value="idat" type="string" offset="4"/>
    </magic>
    <glob pattern="*.qtif"/>
    <glob pattern="*.qif"/>

/usr/share/mime/packages/freedesktop.org.xml

It could be helped by a more robust match value, but it should also not be matched by files that do not match the glob pattern.

$ kmimetypefinder5 --version
kmimetypefinder 5.12.8
Comment 1 Nathaniel Beaver 2020-06-19 23:43:04 UTC
Created attachment 129536 [details]
File that replicates the bug.

Contains just the string "candidate".
Comment 2 Christoph Feck 2020-07-14 21:52:42 UTC
Please report this to XDG mime database maintainers.
Comment 3 Nathaniel Beaver 2020-07-15 01:31:21 UTC
OK, but why is kmimetypefinder matching image/x-quicktime to files that end in .txt, not .qtif or .qif?