Only match real MIME types, not e.g. "raw CD image"
ClosedPublic

Authored by ngraham on Sep 23 2017, 4:38 AM.

Details

Summary

BUG: 364884

Only match real MIME types when doing string matching to prevent pulling in unrelated files whose types match the string.

This prevents weird situations such as ISO files (which show up as "raw CD image") appearing in image searches.

Test Plan
  • Confirmed at www.mime-type.net/ that all audio, video, and image MIME types have the key word before the slash (e.g. "image/")
  • Booted a clean KDE Neon VM and added an ISO and a bunch of pictures of various types
  • Confirmed the problem: baloosearch -t image iso shows ISO files
  • Patched and rebuilt Baloo
  • Forced a re-index operation (balooctl disable; rm ~/.local/share/baloo/index*; balooctl enable)
  • Did a new image search (baloosearch -t image iso) and confirmed that the ISO does not show up
  • Confirmed that other images still show up

Diff Detail

Repository
R293 Baloo
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
ngraham created this revision.Sep 23 2017, 4:38 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptSep 23 2017, 4:38 AM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript

Yes, but then startsWith() would be even more correct (and slightly faster) than contains().

And application/vnd.oasis.opendocument.text isn't plain text, so contains("text") should also be changed to startsWith("text/").

ngraham updated this revision to Diff 19827.Sep 23 2017, 1:42 PM

Use startsWith() instead of contains() for greater speed and correctness, and do this for text MIME types as well

dfaure accepted this revision.Sep 23 2017, 1:55 PM

Yes (although I would then swap document to be after text/, to have all the "groups" together, and then the "substring searches").
In any case feel free to push.

This revision is now accepted and ready to land.Sep 23 2017, 1:55 PM

Ah, excellent idea.

ngraham updated this revision to Diff 19829.Sep 23 2017, 1:57 PM

Grouping the startsWith() and contains() entries

ngraham closed this revision.Sep 23 2017, 1:59 PM