mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
MacOS: create_cstr_from_cfstring uses safe conversion - use CFStringGetCString
During testing with gdk-pixbuf I noticed failures during content type
to mime conversion. The root reason was the unsafe conversion used
in create_cstr_from_cfstring. The problem was addressed in commit
c60226e0a1
but that was reverted. I noticed the commit only
when I had fixed the problem. In addition I added a test to check
the content type to mime conversion on MacOS. This problem is
discussed in Bug #788936.
See: https://bugzilla.gnome.org/show_bug.cgi?id=788936
This commit is contained in:
committed by
Philip Withnall
parent
df7e4db65a
commit
2bd423c54c
@@ -361,6 +361,33 @@ test_guess_svg_from_data (void)
|
||||
g_free (res);
|
||||
}
|
||||
|
||||
static void
|
||||
test_mime_from_content (void)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
gchar *mime_type;
|
||||
mime_type = g_content_type_get_mime_type ("com.microsoft.bmp");
|
||||
g_assert_cmpstr (mime_type, ==, "image/bmp");
|
||||
g_free (mime_type);
|
||||
mime_type = g_content_type_get_mime_type ("com.compuserve.gif");
|
||||
g_assert_cmpstr (mime_type, ==, "image/gif");
|
||||
g_free (mime_type);
|
||||
mime_type = g_content_type_get_mime_type ("public.png");
|
||||
g_assert_cmpstr (mime_type, ==, "image/png");
|
||||
g_free (mime_type);
|
||||
mime_type = g_content_type_get_mime_type ("public.text");
|
||||
g_assert_cmpstr (mime_type, ==, "text/*");
|
||||
g_free (mime_type);
|
||||
mime_type = g_content_type_get_mime_type ("public.svg-image");
|
||||
g_assert_cmpstr (mime_type, ==, "image/svg+xml");
|
||||
g_free (mime_type);
|
||||
#elif defined(G_OS_WIN32)
|
||||
g_test_skip ("mime from content type test not implemented on WIN32");
|
||||
#else
|
||||
g_test_skip ("mime from content type test not implemented on UNIX");
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -370,6 +397,7 @@ main (int argc, char *argv[])
|
||||
|
||||
g_test_add_func ("/contenttype/guess", test_guess);
|
||||
g_test_add_func ("/contenttype/guess_svg_from_data", test_guess_svg_from_data);
|
||||
g_test_add_func ("/contenttype/mime_from_content", test_mime_from_content);
|
||||
g_test_add_func ("/contenttype/unknown", test_unknown);
|
||||
g_test_add_func ("/contenttype/subtype", test_subtype);
|
||||
g_test_add_func ("/contenttype/list", test_list);
|
||||
|
Reference in New Issue
Block a user