[glib] xdgmime: fix special case for mime_type_subclass
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] xdgmime: fix special case for mime_type_subclass
- Date: Tue, 16 May 2017 10:16:57 +0000 (UTC)
commit eb7b796bd206c31e336c89fb828a8a343ffb34ba
Author: Alexandru Pandelea <alexandru pandelea gmail com>
Date: Wed May 10 19:09:35 2017 +0300
xdgmime: fix special case for mime_type_subclass
Currently, all mime types are considered subclasses of
application/octet-stream, but according to the freedesktop
standard, everything but the inode/* types is a subclass of
application/octet-stream.
Update the special case for application/octet-stream so that all
types but inode/* will match with it and add unit test for it.
https://bugzilla.gnome.org/show_bug.cgi?id=782311
gio/tests/contenttype.c | 18 ++++++++++++++++++
gio/xdgmime/xdgmime.c | 3 ++-
gio/xdgmime/xdgmimecache.c | 3 ++-
3 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/gio/tests/contenttype.c b/gio/tests/contenttype.c
index 7930002..1acbd77 100644
--- a/gio/tests/contenttype.c
+++ b/gio/tests/contenttype.c
@@ -324,11 +324,27 @@ test_tree (void)
}
}
+static void
+test_type_is_a_special_case (void)
+{
+ gboolean res;
+
+ g_test_bug ("782311");
+
+ /* Everything but the inode type is application/octet-stream */
+ res = g_content_type_is_a ("inode/directory", "application/octet-stream");
+ g_assert_false (res);
+ res = g_content_type_is_a ("anything", "application/octet-stream");
+ g_assert_true (res);
+}
+
int
main (int argc, char *argv[])
{
g_test_init (&argc, &argv, NULL);
+ g_test_bug_base ("http://bugzilla.gnome.org/");
+
g_test_add_func ("/contenttype/guess", test_guess);
g_test_add_func ("/contenttype/unknown", test_unknown);
g_test_add_func ("/contenttype/subtype", test_subtype);
@@ -338,6 +354,8 @@ main (int argc, char *argv[])
g_test_add_func ("/contenttype/icon", test_icon);
g_test_add_func ("/contenttype/symbolic-icon", test_symbolic_icon);
g_test_add_func ("/contenttype/tree", test_tree);
+ g_test_add_func ("/contenttype/test_type_is_a_special_case",
+ test_type_is_a_special_case);
return g_test_run ();
}
diff --git a/gio/xdgmime/xdgmime.c b/gio/xdgmime/xdgmime.c
index 42dda58..9ba224a 100644
--- a/gio/xdgmime/xdgmime.c
+++ b/gio/xdgmime/xdgmime.c
@@ -791,7 +791,8 @@ _xdg_mime_mime_type_subclass (const char *mime,
strncmp (umime, "text/", 5) == 0)
return 1;
- if (strcmp (ubase, "application/octet-stream") == 0)
+ if (strcmp (ubase, "application/octet-stream") == 0 &&
+ strncmp (umime, "inode/", 6) != 0)
return 1;
parents = _xdg_mime_parent_list_lookup (parent_list, umime);
diff --git a/gio/xdgmime/xdgmimecache.c b/gio/xdgmime/xdgmimecache.c
index 9ea32c8..e2d49ed 100644
--- a/gio/xdgmime/xdgmimecache.c
+++ b/gio/xdgmime/xdgmimecache.c
@@ -925,7 +925,8 @@ _xdg_mime_cache_mime_type_subclass (const char *mime,
strncmp (umime, "text/", 5) == 0)
return 1;
- if (strcmp (ubase, "application/octet-stream") == 0)
+ if (strcmp (ubase, "application/octet-stream") == 0 &&
+ strncmp (umime, "inode/", 6) != 0)
return 1;
for (i = 0; _caches[i]; i++)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]