mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 23:13:40 +02:00
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:
@@ -895,9 +895,18 @@ g_content_type_guess (const char *filename,
|
||||
|
||||
if (filename)
|
||||
{
|
||||
basename = g_path_get_basename (filename);
|
||||
n_name_mimetypes = xdg_mime_get_mime_types_from_file_name (basename, name_mimetypes, 10);
|
||||
g_free (basename);
|
||||
i = strlen (filename);
|
||||
if (filename[i - 1] == '/') {
|
||||
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. */
|
||||
|
Reference in New Issue
Block a user