After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 513413 - provide option to force mime-type sniffing
provide option to force mime-type sniffing
Status: RESOLVED WONTFIX
Product: glib
Classification: Platform
Component: gio
2.15.x
Other Linux
: Normal enhancement
: ---
Assigned To: Alexander Larsson
gtkdev
Depends on:
Blocks:
 
 
Reported: 2008-01-31 11:22 UTC by Felix Riemann
Modified: 2008-02-01 11:03 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement



Description Felix Riemann 2008-01-31 11:22:53 UTC
In gnome-vfs there was the GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE option to the GnomeVFSFileInfo interface which forced the use of mime-type sniffing. GIO doesn't have an equivalent and can be mislead by the filename.

Example (using  G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE):

1. Take a jpeg file and determine its mime type. Should something like "image/jpeg"

2. Rename the file to image.png
3. Check the mime type of that file. It is "image/png".

This can lead to problems if you need to take different actions depending on the mime type.
Comment 1 Alexander Larsson 2008-02-01 11:03:46 UTC
Forcing sniffing of mime types have other kinds of problems, like being extremely slow. And failure in this case is much harder to fix for the user. (you'd have to report the error to freedesktop.org and wait for a new shared-mime-data release, assuming the magic rules can even be fixed).

This has been discussed on the xdg list and we have decided to change the mime spec recommended ordering of sniffing vs globs. I don't think its a good idea to expose the slow mime type in an easy to get way as its not something most apps should use.

However, if you really want to do the sniffing, you can just use g_content_type_guess().