flxzt / rnote

Sketch and take handwritten notes.
https://rnote.flxzt.net
GNU General Public License v3.0
8k stars 274 forks source link

Failing to copy to clipboard large files #1022

Closed Doublonmousse closed 7 months ago

Doublonmousse commented 7 months ago

Describe the bug
Large images (svg and png) will fail to be copied to the clipboard if they are too large (~ 4 Mo is already too much)

To Reproduce
Steps to reproduce the behavior:

  1. paste a large image in a rnote document
  2. try to copy it
  3. try to paste it
  4. See that the image is not pasted

Expected behavior
Have the image be copied to the clipboard

Console Output

read stream to rsvg loader failed.

or

reading stream to rsvg loader failed.

Desktop (please complete the following information):

Additional context

This is a limitation of librsvg if the loader is not called with an unlimited size, see here : https://gitlab.gnome.org/GNOME/librsvg/-/issues/819

So calling

rsvg::Loader::new()
            .with_unlimited_size(true)

instead of

rsvg::Loader::new()

fixes the issue.

flxzt commented 7 months ago

This is also an issue when exporting, right?

Doublonmousse commented 7 months ago

Yeah, I'm pretty sure it can happen when exporting. Though the size of files you need for it to happen is quite large so it's quite normal no one found the issue before.

The rsvg-convert page says this about the unlimited -u option

       -u --unlimited
              The SVG parser has some guards designed to mitigate large CPU or
              memory consumption in the face of malicious XML.   It  may  also
              refuse  to  resolve  URIs  used to embed image data.  If you are
              running into such issues when  converting  a  SVG,  this  option
              allows to turn off these guards.