Crash opening invalid svg (attribute without value in filter node)

Summary:

Inkscape crashes when opening an SVG file where the auto-region="false" <filter> attribute has accidentally been split mid-word (in this case, before gion).

Yes, the file is corrupt, but user input should never be able to crash an application.

Steps to reproduce:

  • Open "Crash.svg" (attached)

What happened?

Inkscape crashed with the following output:

/path/to/Crash.svg:55: parser error : Specification mandates value for attribute auto-re
gion="false">
^
/path/to/Crash.svg:55: parser error : attributes construct error
gion="false">
^
/path/to/Crash.svg:55: parser error : Couldn't find end of Start Tag filter line 50
gion="false">
^
/path/to/Crash.svg:60: parser error : Opening and ending tag mismatch: defs line 48 and filter
  </filter>
           ^
/path/to/Crash.svg:61: parser error : Opening and ending tag mismatch: svg line 4 and defs
</defs>
       ^
/path/to/Crash.svg:62: parser error : Extra content at the end of the document
<g
^

Emergency save activated!
Emergency save completed. Inkscape will close now.
If you can reproduce this crash, please file a bug at https://inkscape.org/report
with a detailed description of the steps leading to the crash, so we can fix it.
Speicherzugriffsfehler (Speicherabzug geschrieben)

What should have happened?

Either of those (my preference would be 2):

  1. Inkscape should have complained about a corrupt file and not opened it, but also not crashing
  2. Inkscape should have complained and just ignored that particular attribute

Sample attachment:

Crash.svg

Version info

Inkscape 1.1.1 (3bf5ae0d25, 2021-09-20)

    GLib version:     2.68.4
    GTK version:      3.24.30
    glibmm version:   2.64.2
    gtkmm version:    3.24.5
    libxml2 version:  2.9.12
    libxslt version:  1.1.34
    Cairo version:    1.16.0
    Pango version:    1.48.10
    HarfBuzz version: 2.7.4
    Poppler version:  21.06.1

    OS version:       Ubuntu 21.10
Edited by Nathan Lee
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information