GNOME Bugzilla – Bug 143433
get MIME type wrong for Multi-byte filename
Last modified: 2004-12-22 21:47:04 UTC
* login into chinese locale (non UTF-8, e.g., GB18030) * double click on one ".doc" icon which filename consists of some multi-byte chars. e.g. "da, jia"
gnome_vfs_get_file_mime_type() ... -> ... -> _xdg_glob_has_lookup_file_name(), this function will lookup the extention of the given path, but it treats the path as UTF-8 encoding, so when it skips utf-8 chars to lookup '.', the '.' maybe incorrectly skipped. (An array _xdg_utf8_skip[] will be used to determin skipping pace.) for (ptr = file_name; *ptr != '\000'; ptr++ /*= _xdg_utf8_next_char (ptr)*/) { if (*ptr == '.') { mime_type = (_xdg_glob_hash_node_lookup_file_name (glob_hash->simple_node, ptr, FALSE)); if (mime_type != NULL) return mime_type; } } ... ...
Oops, a typo, should be _xdg_glob_hash_lookup_file_name().
*** Bug 141818 has been marked as a duplicate of this bug. ***
This one is probably a pain to fix because we cannot use glib conversion api :((
Actually maybe gnome-vfs could do the conversion before passing it to xdgmime.
The thing is that we cannot do a conversion because this apply to remote filenames too and we dont know the encoding for these.
Talked with alex about this. I think we need to fix both gnome-vfs and xdgmime to not assume it's utf8. That's possible because in all encodings actually used for the filesystem you can assume ascii caracters are actually represented as ascii (i.e. a strchr('.') will work correctly).
Created attachment 34771 [details] [review] fix