Bug 551681 – g_content_type_guess() too naive with filenames

* gcontenttype.c (g_content_type_guess): Check whether there's a '/'
        at the end of the filename, and declare it a directory.
        Patch by Bastien Nocera


svn path=/trunk/; revision=7491
This commit is contained in:
Matthias Clasen 2008-09-15 16:06:05 +00:00
parent 4b92cd39fd
commit f634171ec5
2 changed files with 20 additions and 3 deletions

View File

@ -1,3 +1,11 @@
2008-09-15 Matthias Clasen <mclasen@redhat.com>
Bug 551681 g_content_type_guess() too naive with filenames
* gcontenttype.c (g_content_type_guess): Check whether there's a '/'
at the end of the filename, and declare it a directory.
Patch by Bastien Nocera
2008-09-14 Cosimo Cecchi <cosimoc@gnome.org> 2008-09-14 Cosimo Cecchi <cosimoc@gnome.org>
Bug 551887 Docs for g_desktop_app_info_new_from_filename () Bug 551887 Docs for g_desktop_app_info_new_from_filename ()

View File

@ -895,9 +895,18 @@ g_content_type_guess (const char *filename,
if (filename) if (filename)
{ {
basename = g_path_get_basename (filename); i = strlen (filename);
n_name_mimetypes = xdg_mime_get_mime_types_from_file_name (basename, name_mimetypes, 10); if (filename[i - 1] == '/') {
g_free (basename); char *mimetypes[] = { "inode/directory", NULL };
name_mimetypes = g_strdupv (mimetypes);
n_name_mimetypes = 1;
if (result_uncertain)
*result_uncertain = TRUE;
} else {
basename = g_path_get_basename (filename);
n_name_mimetypes = xdg_mime_get_mime_types_from_file_name (basename, name_mimetypes, 10);
g_free (basename);
}
} }
/* Got an extension match, and no conflicts. This is it. */ /* Got an extension match, and no conflicts. This is it. */