svg xml with weird non-utf8 content causes an ugly traceback

Bug #1823757 reported by Daniel Manrique
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snap Store Server
Fix Released
Medium
Maximiliano Bertacchini

Bug Description

how to reproduce:

- go to snapcraft.io, developer account, choose any snap...
- try to upload the specially-crafted evil svg, contains something like this (best to download the attachment, as the key is the funky xpacked non-utf8 data):
<?xml version="1.0" standalone="no"?>
<svg width="600" height="800">
<?xpacket begin="�"" id="W5M0MpCehiHzreSzNTczkc9d"?>
  <rect width="600" height="800" style="fill:rgb(0,0,255)" />
  <circle cx="300" cy="400" r="300" style="fill:rgb(255,0,0)" />
</svg>

Expected result:
- "Icon: The image file 'bogon.svg' is not valid (we can't open it)."
- No sentry tracebacks because we don't need to be spammed every time someone uploads a weird file

Actual result:
- "Icon: The image file 'bogon.svg' is not valid (we can't open it)." (OK, nice friendly user-facing error)
- A sentry traceback!!

https://sentry.ols.canonical.com/canonical/snapcraft-dashboard/issues/7976/

IOError: Could not convert SVG file: Error reading SVG:Error domain 1 code 9 on line 1 column 1 of file:///tmp/tmp_q0iEj.svg: Input is not proper UTF-8, indicate encoding !
Bytes: 0xFF 0x22 0x22 0x20

  File "devportal/forms.py", line 457, in make_icon_file
    data = make_icon_png_file(data, size, enforce_size=enforce_size)
  File "devportal/forms.py", line 432, in make_icon_png_file
    data = _make_simple_png_uploaded_file(data, size)
  File "devportal/forms.py", line 396, in _make_simple_png_uploaded_file
    raise IOError(msg)

Worth checking if we really want to bubble this to a sentry error. The file is clearly malformed, which appears to be due to a bug in inkscape (although without access to the file that triggered this originally, we can't tell whether it was indeed created by inkscape).

Without access to rsvg-convert, it's likely the user wouldn't have way of verifying why inkscape can open the file but we can't.

Revision history for this message
Daniel Manrique (roadmr) wrote :
Revision history for this message
Daniel Manrique (roadmr) wrote :
summary: - xml with weird non-utf8 content causes an ugly traceback
+ svg xml with weird non-utf8 content causes an ugly traceback
Revision history for this message
Daniel Manrique (roadmr) wrote :

On our side, this is working as implemented - the code handles malformed svgs properly, but logger.exception()'s which results in sentry alerts, the rationale being that we do want to know when someone tries to upload a malformed svg and why.

Options would be to logger.warning instead so we have it in the logs but not raising sentry alerts, or using another svg parser/renderer which can grok those faily inkscape svgs.

Changed in snapstore:
status: New → Triaged
importance: Undecided → Medium
Changed in snapstore:
status: Triaged → In Progress
assignee: nobody → Maximiliano Bertacchini (maxiberta)
Changed in snapstore:
status: In Progress → Fix Committed
Changed in snapstore:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

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