GNOME Bugzilla – Bug 512691
Content type should not be detected from the extension.
Last modified: 2008-01-29 10:41:04 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".
Changed summary to be more meaningful, sorry for the spam.
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.
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.
Isn't this what shared-mime-info is supposed to solve? It has both patterns for file contents and file extensions...
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.