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 512691 - Content type should not be detected from the extension.
Content type should not be detected from the extension.
Product: glib
Classification: Platform
Component: gio
Other Linux
: Normal critical
: ---
Assigned To: Alexander Larsson
Depends on:
Blocks: 510401
Reported: 2008-01-29 00:06 UTC by Cosimo Cecchi
Modified: 2008-01-29 10:41 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22

Description Cosimo Cecchi 2008-01-29 00:06:02 UTC
To reproduce in Nautilus (and any other application using GIO, e.g. Evince, see comments on bug #510401)

- Take a .pdf file
- rename it to .jpeg
- it changes its mime type to image/jpeg

Note that this does not happen (as it should be) if you rename the file to a not known extension, like ".foo".
Comment 1 Cosimo Cecchi 2008-01-29 00:12:40 UTC
Changed summary to be more meaningful, sorry for the spam.
Comment 2 Bastien Nocera 2008-01-29 00:25:03 UTC
Content type is detected from extension, unless you use something like g_content_type_guess() with a NULL filename, and provide data.

Using g_content_type_guess() will also return whether the content_type is uncertain. Finally, a content type isn't a mime-type on Windows, so I guess your checks would be broken on Windows as well.
Comment 3 Cosimo Cecchi 2008-01-29 00:39:19 UTC
I don't think Windows behaviour (getting type from the extension) is a good thing, and IIRC this is a regression from gnome-vfs.
From g_file_info_get_content_type (), I expect the real content type of the file, or a guess from the real content, not from the extension. Also, this breaks Nautilus and all the other applications who want e.g. to launch a GAppInfo based from a content type.
Comment 4 Wouter Bolsterlee (uws) 2008-01-29 09:35:17 UTC
Isn't this what shared-mime-info is supposed to solve? It has both patterns for file contents and file extensions...
Comment 5 Alexander Larsson 2008-01-29 10:41:04 UTC
This works as designed, and the shared mime spec is being updated. 
Sniffing by mimetype is slow and has other problems. For more info see the discussions on the xdg list.