gdk-pixbuf fails to recognize svg file with long comments at top

Bug #926019 reported by Walter Mundt
18
This bug affects 4 people
Affects Status Importance Assigned to Milestone
GDecrypt
New
Undecided
Unassigned
gdk-pixbuf (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

In precise, the current gdecrypt package doesn't work. It crashes with this error:

Traceback (most recent call last):
  File "./main.py", line 609, in <module>
    gdc = gdecrypt()
  File "./main.py", line 127, in __init__
    pixbuf128 = gtk.icon_theme_get_default().load_icon("gdecrypt",128,0)
glib.GError: Unrecognized image file format

I checked, and it is attempting to load /usr/share/icons/hicolor/scalable/apps/gdecrypt.svg and failing.

The file loads up just fine in eog and inkscape, and appears to be perfectly a valid svg. In Python, you can try to load it directly:
$ cd /usr/share/icons/hicolor/scalable/apps
$ python
>>> import gtk
>>> gtk.gdk.pixbuf_new_from_file("gdecrypt.svg")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
glib.GError: Couldn't recognize the image file format for file 'gdecrypt.svg'
>>> gtk.gdk.pixbuf_get_file_info("gdecrypt.svg")
>>> gtk.gdk.pixbuf_get_file_info("gnome-panel.svg")
({'is_writable': False, 'extensions': ['svg', 'svgz', 'svg.gz'], 'mime_types': ['image/svg+xml', 'image/svg', 'image/svg-xml', 'image/vnd.adobe.svg+xml', 'text/xml-svg', 'image/svg+xml-compressed'], 'name': 'svg', 'description': 'Scalable Vector Graphics'}, 48, 48)

Comparing the two leads to one important difference. gnome-panel.svg starts with:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
...

gdecrypt.svg, on the other hand:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<!-- Copyright (C) 2007 Kjell Braden
      Permission is granted to copy, distribute and/or modify this
      document under the terms of the GNU General Public License,
      Version 3 or any later version published by the Free Software
      Foundation. -->
<svg
...

If the copyright notice is removed, the icon loads just fine and everything works. However, the comment is well-formed and there's nothing I'm aware of forbidding svg files from containing comments of any length ahead of the document root tag. As such, it is not generally safe to use MIME magic that only looks at the beginning of the file to detect the svg format. I have no suggestions as to how to solve this in the general case, but I suspect that it is what is happening here, and there's no good reason not to use the file extension to determine the type of the icon right here.

While I ran into this in trying out gdecrypt, I believe this is clearly a gdk-pixbuf issue that is merely negatively affecting that package, so I'm filing this bug against the latter package.

Revision history for this message
Walter Mundt (waltermundt) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gdk-pixbuf (Ubuntu):
status: New → Confirmed
tags: added: rls-w-incoming
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.