Bug 423251 - kmimetypefinder5 misidentifies some text files as image/x-quicktime
Summary: kmimetypefinder5 misidentifies some text files as image/x-quicktime
Status: RESOLVED UPSTREAM
Alias: None
Product: kde-cli-tools
Classification: Plasma
Component: general (other bugs)
Version First Reported In: 5.12.8
Platform: Ubuntu Linux
: NOR minor
Target Milestone: ---
Assignee: Aleix Pol
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-19 23:41 UTC by Nathaniel Beaver
Modified: 2020-07-15 01:31 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
File that replicates the bug. (10 bytes, text/plain)
2020-06-19 23:43 UTC, Nathaniel Beaver
Details

Note You need to log in before you can comment on or make changes to this 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?