Summary: | kmimetypefinder incorrectly detects some ISO files as 'text/plain' type, while other ISO files are detected correctly | ||
---|---|---|---|
Product: | [Unmaintained] kdelibs | Reporter: | i.Dark_Templar <idarktemplar> |
Component: | general | Assignee: | kdelibs bugs <kdelibs-bugs> |
Status: | RESOLVED DUPLICATE | ||
Severity: | normal | CC: | rdieter |
Priority: | NOR | ||
Version: | 4.14.0 | ||
Target Milestone: | --- | ||
Platform: | Gentoo Packages | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
i.Dark_Templar
2015-04-27 17:21:41 UTC
Dump of first 128 bytes of each image: $ for i in *.iso ; do echo FILE $i ; hexdump -n 128 -C $i ; echo ; done FILE FreeBSD-10.1-RELEASE-i386-disc1.iso 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000080 FILE FreeBSD-9.3-RELEASE-i386-bootonly.iso 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000080 FILE install-x86-minimal-20140930.iso 00000000 33 ed 90 90 90 90 90 90 90 90 90 90 90 90 90 90 |3...............| 00000010 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 |................| 00000020 33 ed fa 8e d5 bc 00 7c fb fc 66 31 db 66 31 c9 |3......|..f1.f1.| 00000030 66 53 66 51 06 57 8e dd 8e c5 52 be 00 7c bf 00 |fSfQ.W....R..|..| 00000040 06 b9 00 01 f3 a5 ea 4b 06 00 00 52 b4 41 bb aa |.......K...R.A..| 00000050 55 31 c9 30 f6 f9 cd 13 72 16 81 fb 55 aa 75 10 |U1.0....r...U.u.| 00000060 83 e1 01 74 0b 66 c7 06 f1 06 b4 42 eb 15 eb 00 |...t.f.....B....| 00000070 5a 51 b4 08 cd 13 83 e1 3f 5b 51 0f b6 c6 40 50 |ZQ......?[Q...@P| 00000080 FILE livedvd-x86-amd64-32ul-20140826.iso 00000000 45 52 08 00 00 00 90 90 00 00 00 00 00 00 00 00 |ER..............| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000020 33 ed fa 8e d5 bc 00 7c fb fc 66 31 db 66 31 c9 |3......|..f1.f1.| 00000030 66 53 66 51 06 57 8e dd 8e c5 52 be 00 7c bf 00 |fSfQ.W....R..|..| 00000040 06 b9 00 01 f3 a5 ea 4b 06 00 00 52 b4 41 bb aa |.......K...R.A..| 00000050 55 31 c9 30 f6 f9 cd 13 72 16 81 fb 55 aa 75 10 |U1.0....r...U.u.| 00000060 83 e1 01 74 0b 66 c7 06 f1 06 b4 42 eb 15 eb 00 |...t.f.....B....| 00000070 5a 51 b4 08 cd 13 83 e1 3f 5b 51 0f b6 c6 40 50 |ZQ......?[Q...@P| 00000080 FILE xubuntu-14.04.1-desktop-i386.iso 00000000 33 ed 90 90 90 90 90 90 90 90 90 90 90 90 90 90 |3...............| 00000010 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 |................| 00000020 33 ed fa 8e d5 bc 00 7c fb fc 66 31 db 66 31 c9 |3......|..f1.f1.| 00000030 66 53 66 51 06 57 8e dd 8e c5 52 be 00 7c bf 00 |fSfQ.W....R..|..| 00000040 06 b9 00 01 f3 a5 ea 4b 06 00 00 52 b4 41 bb aa |.......K...R.A..| 00000050 55 31 c9 30 f6 f9 cd 13 72 16 81 fb 55 aa 75 10 |U1.0....r...U.u.| 00000060 83 e1 01 74 0b 66 c7 06 f1 06 b4 42 eb 15 eb 00 |...t.f.....B....| 00000070 5a 51 b4 08 cd 13 83 e1 3f 5b 51 0f b6 c6 40 50 |ZQ......?[Q...@P| 00000080 I've checked sources. It looks like function KMimeTypeRepository::findFromContent is called, it doesn't recognize some of those images and falls back to function KMimeType::isBufferBinaryData which reports it being valid text files. Here's one possible way to fix it: 1) make sure that KMimeType::isBufferBinaryData uses 'isgraph || isspace' functions (or their locale-aware versions) to check that each byte is a valid printable or space or newline character. 2) if contents mime detection fails (accuracy == 0), fallback on mime detection by file name. It may be made either inside KMimeType class or inside kmimetypefinder application. Here's another one: 1) By default behaviour make kmimetypefinder obtain mime type both based on filename and contents, and if contents mime accuracy is greater than filename mime accuracy then report contents mime, otherwise report filename mime. Both fixes may be implemented/combined too. More information: I've just downloaded xubuntu-15.04-desktop-i386.iso from http://xubuntu.org/getxubuntu/. I guess using other images from that page would provide same results. I've also downloaded FreeBSD-10.1-RELEASE-i386-bootonly.iso from ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/i386/ISO-IMAGES/10.1/ $ file --mime-type *.iso FreeBSD-10.1-RELEASE-i386-bootonly.iso: application/x-iso9660-image xubuntu-15.04-desktop-i386.iso: application/x-iso9660-image $ for i in *.iso ; do echo -n -e "\n$i:\t" ; kmimetypefinder $i ; done FreeBSD-10.1-RELEASE-i386-bootonly.iso: application/x-cd-image (accuracy 20) xubuntu-15.04-desktop-i386.iso: text/plain (accuracy 5) $ LC_ALL=C kmimetypefinder --version Qt: 4.8.6 KDE Development Platform: 4.14.3 MimeType Finder: 4.14.3 see bug #337035 and freedesktop.org upstream bug, https://bugs.freedesktop.org/show_bug.cgi?id=80877 *** This bug has been marked as a duplicate of bug 337035 *** |