Parser error displayed when rendering SVG with UTF-8 encoded characters via --pipe, but actually renders fine

Summary:

When rendering SVG passed via a pipe and using --pipe where the SVG contains UTF-8 encoded characters, I get a parser error similar to the following (the file contained two ä in this case):

Entity: line 55: parser error : expected '>'
</svg
     ^

Interestingly, it seems like the file is actually rendered fine.

Steps to reproduce:

  • Download the attached utf-8.svg sample file
  • Try to convert it using a command like inkscape --export-filename="output-utf-8-pipe.png" --pipe < utf-8.svg

What happened?

I get the above error, but the generated PNG file looks fine.

What should have happened?

There should be no error.

Remarks:

Adding enough spaces or empty lines (or the right number of random characters) at the end of the SVG (after the closing tag) seems to avoid these messages/errors, so does converting the SVG to ASCII and using XML entities for the two ä, like I did in ascii.svg. Converting the files without using the pipe and --pipe does not result in these messages. The attached run.sh script can be used to test some of these combinations. The files resulting from running the conversions with the script all seem to be identical.

To me, it seems like the parser that emits this error only gets as many bytes of the SVG as there are characters in the SVG, not as many as there are bytes in it (when considering e.g. ä as one character which is two bytes in UTF-8). So adding more UTF-8 characters to the <tspan> element can also yield other errors like parser error : internal error: detected an error in element content which likely results from the parser getting less and less of the SVG's content.

Adding even more characters at the end of the files results in a parser error : Extra content at the end of the document but the file also seems to be rendered fine, but that's probably a different issue and invalid XML anyway - and consistent with not using a pipe and --pipe.

Sample attachments:

  • utf-8.svg - UTF-8 encoded file
  • ascii.svg - ASCII encoded file
  • run.sh - script to run conversions

Version info:

I'm using the packages from Debian on Bullseye/Stable and Sid/Unstable and get pretty much the same output on both versions .

Debian Sid/Unstable:

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

    GLib version:     2.70.1
    GTK version:      3.24.30
    glibmm version:   2.66.1
    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:  20.09.0

    OS version:       Debian GNU/Linux bookworm/sid

Debian Bullseye:

Inkscape 1.0.2 (e86c870879, 2021-01-15)
    Pango version: 1.46.2