#574579 glib reports wrong mimetype of svg file with long comments

Package:
shared-mime-info
Source:
shared-mime-info
Description:
FreeDesktop.org shared MIME database and spec
Submitter:
Darren Hoo
Date:
2015-09-20 08:03:15 UTC
Severity:
minor
#574579#5
Date:
2010-03-19 05:15:40 UTC
From:
To:
Today after I  updated Gtk+  I found that Emacs icon would
not show on the desktop.it seems that gtk's pixbufloader has
something wrong with the Emacs's svg icon.And nautilus can
not generated thumbnail for it too.it's ok with other svg icons
like evince.svg. In the file:
"/usr/share/icons/hicolor/scalable/apps/emacs23.svg"
iceweasel can show the svg image without problem.
if I delete the first comment which is GPL licence,then it
shows the icon without problem.

I test it with the following code (pixmap.c):

pixmapwid = gtk_image_new_from_file (
      "/usr/share/icons/hicolor/scalable/apps/emacs23.svg");
gtk_widget_show (pixmapwid);

with the orignial emacs23.svg:
strace -o strace_with_coment_in_svg.txt ./pixmap

and deleted the first comment in emacs23.svg:
strace -o strace_without_coment_in_svg.txt ./pixmap

The files are attatched for investigation

Thanks.

#574579#10
Date:
2010-03-21 06:55:32 UTC
From:
To:
retitle 574579 glib reports wrong mimetype of svg file with long comments
reassign  574579  shared-mime-info 0.71-1
tags  574579 +patch
thanks

After some digging, I found out that svg image with long comments at
the beginning can not show itself on  gtk widgets, is because glib reports
the wrong mimetype 'application/xml' instead of 'application/svg+xml',
so the pixbufloader can not find the correct svg_loader.

here's the testing code I used:
----------------------------------------------------------- #include <gtk/gtk.h> #include <glib/gprintf.h> #include <errno.h> int main(){ FILE *f; guchar buffer [1024]; gboolean uncertain; gchar *mime_type; guint size; const char *filename = "emacs23.svg"; f = g_fopen (filename, "rb"); if ( f == -1) { g_printf("open failed %s \n",g_strerror(errno)); return 1; } size = fread (&buffer, 1, sizeof (buffer), f); if(size == 0){ g_printf("No image data"); } mime_type = g_content_type_guess (NULL, buffer, size, &uncertain); if (uncertain) mime_type = g_content_type_guess (filename, buffer, size, NULL); g_printf("%s \n", mime_type); } ----------------------------------------------------------- here it returns 'application/xml' with uncertain set to false. with an offset of 256 in the svg section of freedesktop.org.xml is too small, I think increasing it to 1024 is reasonable. to update the mime cache we have to run: update-mime-database /usr/share/mime after changing freedesktop.org.xml
--------------------------------------------------------------
--- /tmp/freedesktop.org.xml 2010-03-21 14:39:14.730266924 +0800 +++ freedesktop.org.xml 2010-03-21 14:38:40.000000000 +0800 @@ -16246,7 +16246,7 @@ <sub-class-of type="application/xml"/> <magic priority="80"> <match value="<!DOCTYPE svg" type="string" offset="0:256"/> - <match value="<svg" type="string" offset="0:256"/> + <match value="<svg" type="string" offset="0:1024"/> </magic> <glob pattern="*.svg"/> </mime-type>
#574579#31
Date:
2015-09-20 08:02:57 UTC
From:
To:
Upstream considered this as something that is not going to be fixed in
shared-mime-info, and I agree with the rationale given there.

Let's consider this as wontfix then.