mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-16 04:28:05 +02:00
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
This commit is contained in:
parent
ac40b56ecb
commit
eb7b796bd2
@ -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
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
g_test_init (&argc, &argv, NULL);
|
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/guess", test_guess);
|
||||||
g_test_add_func ("/contenttype/unknown", test_unknown);
|
g_test_add_func ("/contenttype/unknown", test_unknown);
|
||||||
g_test_add_func ("/contenttype/subtype", test_subtype);
|
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/icon", test_icon);
|
||||||
g_test_add_func ("/contenttype/symbolic-icon", test_symbolic_icon);
|
g_test_add_func ("/contenttype/symbolic-icon", test_symbolic_icon);
|
||||||
g_test_add_func ("/contenttype/tree", test_tree);
|
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 ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
@ -791,7 +791,8 @@ _xdg_mime_mime_type_subclass (const char *mime,
|
|||||||
strncmp (umime, "text/", 5) == 0)
|
strncmp (umime, "text/", 5) == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (strcmp (ubase, "application/octet-stream") == 0)
|
if (strcmp (ubase, "application/octet-stream") == 0 &&
|
||||||
|
strncmp (umime, "inode/", 6) != 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
parents = _xdg_mime_parent_list_lookup (parent_list, umime);
|
parents = _xdg_mime_parent_list_lookup (parent_list, umime);
|
||||||
|
@ -925,7 +925,8 @@ _xdg_mime_cache_mime_type_subclass (const char *mime,
|
|||||||
strncmp (umime, "text/", 5) == 0)
|
strncmp (umime, "text/", 5) == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (strcmp (ubase, "application/octet-stream") == 0)
|
if (strcmp (ubase, "application/octet-stream") == 0 &&
|
||||||
|
strncmp (umime, "inode/", 6) != 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (i = 0; _caches[i]; i++)
|
for (i = 0; _caches[i]; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user