Tk Source Code

View Ticket
Login
Ticket UUID: ea665e08f39e564ee572d15226c7b2a873f2c88d
Title: Endless loop when reading svg file
Type: Bug Version: trunk
Submitter: fvogel Created on: 2020-09-16 20:58:11
Subsystem: 41. Photo Images Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2020-09-22 08:04:23
Resolution: Fixed Closed By: oehhar
    Closed on: 2020-09-22 08:04:23
Description:

From https://github.com/memononen/nanosvg/issues/178#issuecomment-693004606:

Endless loop when running:

package require Tk
set data { <g transform="skewX(1 1)> }
image create photo foo -data $data

User Comments: oehhar added on 2020-09-22 08:04:23:

Ok, thank you.

The patch is also in package tksvg release 0.5 for tcl8.6.x: https://github.com/oehhar/tksvg/releases/tag/0.5

Thanks, Harald


fvogel added on 2020-09-21 20:02:29:

I have added a non regresion test in the bugfix branch and have merged this branch into trunk.

Upstream took the patch as well. Very good!

Regarding bug-d6e9b4db_svg-match-big-file, I'm not sure. I have to think about it. However, discussions about this should happen in the corresponding ticket [d6e9b4db40], not here.

I'm closing the present ticket now since what it deals with has been fixed.


oehhar added on 2020-09-21 11:58:21:

At nanosvg, the patch is attached to the ticket and a pull-request is created. I don't thnk we can do more.

THank you, Harald


oehhar added on 2020-09-21 11:28:41:

Francois,

thank you for the comments.

I propose to:

  • merge the patch branch [bug-ea665e08f3] to trunk
  • add a test with the testdata (with "<?xml..", so it will still trigger, if [bug-d6e9b4db_svg-match-big-file] is merged.
  • I will reports your patch to the svgnano ticket.
  • Also merge branch [bug-d6e9b4db_svg-match-big-file]
  • Update package tksvg

Any comments?

If ok, I will do so on Wednsday.

Thank you, Harald


fvogel added on 2020-09-18 21:38:30:

Oh, and about your remark:

>Up to now, we have avoided to modify svgnano.

It really is a bug in the svgnano parser, which doesn't correctly handle erroneous syntax in parameters of the 'transform' attribute. When there are more parameters than expected, the parser loops endlessly. This really must be corrected in the parser, and this is what my fix does.

Now if you can convince some still living soul upstream to take this fix and include it in svgnano, that would be great. I agree that this issue should ideally be best fixed upstream in svgnano.


fvogel added on 2020-09-18 21:26:32:

> With the proposal in branch bug-d6e9b4db_svg-match-big-file, the issue will not be triggered

Incorrect (and this is fortunate, otherwise my fix would be wrong!). This branch also has the same problem, you just have to provide it with a slightly more elaborated svg file:

package require Tk
set data {<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<g transform="skewX(1 1)>
}
image create photo foo -data $data

--> endless loop!!


oehhar added on 2020-09-17 07:18:01:

Francois,

thank you for the fix, that is great.

With the proposal in branch [bug-d6e9b4db_svg-match-big-file], the issue will not be triggered, as the parser will not get any data without valid svg tags.

Up to now, we have avoided to modify svgnano. Nevertheless, I think, it is good to apply your patch and to use the new parser.

Thank you for the great action, Harald


fvogel added on 2020-09-16 20:59:55:

Fix proposal: [6450b26902]