Problems with mimetype recognition
Andras Mantia
amantia at kde.org
Wed Oct 1 09:26:02 BST 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
Altough we have a method to determine if a file is text or not with the help
of mimetypes and the [X-KDE-Text] property, I still got reports about users
who say that their PHP files are not recognized as text ones. I got an
example file from them and was surprised to see that the mimetype detection
fails in KMimeType. In KMimeType::findFormatByFileContent first the mimetype
is queried with findByFileContent() which calls
KMimeMagic::self()->findFileType() on it's own. This call returns for the PHP
file in case "application/octet-stream" and for another which is recognized
as text file, suprise: "text/x-c++-src". So even for files that were
recognized as text, it was only by chance as they were not treated as PHP.
This means that either the "magic code" is broken or the magic fields for PHP
are broken. Can someone with more knowledge take a look? If needed, I can
send the files in question.
I think a workaround would be to use findByURL() instead of
findByFileContent() as that one first tries a match by the extension, but
this doesn't solve the problem that findByFileContent() returns the wrong
mimetype.
Andras
- --
Quanta Plus developer - http://quanta.sourceforge.net
K Desktop Environment - http://www.kde.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)
iD8DBQE/eo+aTQdfac6L/08RAqh+AJ0TCEyGZeL/ZEIt9pJZokvTtzXlRwCg4cB7
ccLrBGOjfGZmOT/8031q778=
=wVgJ
-----END PGP SIGNATURE-----
More information about the kde-core-devel
mailing list