glib r7491 - trunk/gio



Author: matthiasc
Date: Mon Sep 15 16:06:05 2008
New Revision: 7491
URL: http://svn.gnome.org/viewvc/glib?rev=7491&view=rev

Log:
        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



Modified:
   trunk/gio/ChangeLog
   trunk/gio/gcontenttype.c

Modified: trunk/gio/gcontenttype.c
==============================================================================
--- trunk/gio/gcontenttype.c	(original)
+++ trunk/gio/gcontenttype.c	Mon Sep 15 16:06:05 2008
@@ -895,9 +895,18 @@
   
   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. */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]