Shared-mime-info prefers a Windows cursor (image/x-win-bitmap) over an uncompressed TGA (image/x-tga). Windows cursor: <magic priority="50"> <match type="string" value="\0\0\2\0" offset="0"> <match type="string" value="\0" offset="5"/> </match> </magic> TGA image: <magic priority="10"> <match type="string" value="\1\1" offset="1"/> <match type="string" value="\1\9" offset="1"/> <match type="string" value="\0\3" offset="1"/> <match type="string" value="\0\xa" offset="1"/> <match type="string" value="\0\xb" offset="1"/> <match type="string" value="\0\2" offset="1"/> <!-- Same magic as CUR files --> </magic> (Only the last match tag is important for _uncompressed_ TGA images.) Unfortunately this breaks applications that depends on the correct MIME type recognition from the file content. For example, geegie [1] is affected. Geeqie uses pixbuf loader from gdk-pixbuf that is tricked into using an ICO loader instead of a TGA loader in such a case. Attached patch tries to address this issue. It utilizes the byte at the offset 16 (0x10). In the TGA file format [2] this byte contains 'Pixel depth'. Common values are 8, 16, 24 and 32. In the CUR file format [3] this byte is part of a DWORD that specifies a number of bytes of the first cursor resource. It's the third byte in that DWORD meaning it contains a value of bits 16-23 (little-endian). This byte should always be 0 because cursor images are relatively small. (For example, among Win 7 system cursors the highest value of this DWORD is 0x25a8.) The patch adds check of the offset 16 only to the uncompressed TGA file magic but you might consider adding it to all other TGA file patterns, or making CUR file magic more strict. [1] http://geeqie.sourceforge.net/ [2] http://www.dca.fee.unicamp.br/~martino/disciplinas/ea978/tgaffs.pdf [3] http://www.digicamsoft.com/bmp/bmp.html
Created attachment 49400 [details] [review] [PATCH] Improve magic of uncompressed TGA files
Pushed, thanks
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.