Review Request: KMimeTypeFactory: Fix handling of mixed case fast patterns

Anssi Hannula anssi at
Thu Jul 1 09:19:31 BST 2010

This is an automatically generated e-mail. To reply, visit:

(Updated 2010-07-01 08:19:31.425290)

Review request for kdelibs.


Right, added a testcase now (using *.Z), and confirmed that the testcase fails on trunk without the fix.


A mimetype glob is put into the "fast pattern" list when its weight is 50, it is in simple "*.foo" format, and it is case-insensitive (KBuildMimeTypeFactory::savePatternLists()). The pattern is lowercased when put into the fast pattern list. When MimeTypeFactory::findFromFastPatternDict() finds a match for a file extension, it checks the returned mimetype to make sure its patterns() list contains the searched pattern. However, the patterns() list contains the patterns in their original format, which may contain mixed case characters, therefore failing the test and the correct mimetype is not returned.

Fix that by adding Qt::CaseInsensitive to the .contains() call.

The two other pattern lists (low weight patterns and high weight patterns) are not affected as KMimeTypeFactory::findFromOtherPatternList() doesn't recheck the patterns() list of the returned mimetype.

This bug affects 4.4 branch as well.

Diffs (updated)

  /trunk/KDE/kdelibs/kdecore/services/kmimetypefactory.cpp 1141627 
  /trunk/KDE/kdelibs/kdecore/tests/kmimetypetest.cpp 1141627 



"kde-open file.EZHex", while the MIME type was defined with a glob "*.EZHex" (from libconcord/congruity).
Before the patch it was opened in a web browser (*.EZHex files are XML based data), after the patch it is opened in the correct application associated with "*.EZHex".
Testing was done on a KDE 4.4 system, but the relevant code seems to be the same in trunk.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the kde-core-devel mailing list