extension "Visualize Path"/"Measure path..." fails

Bug #1641111 reported by Carlos on 2016-11-11
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Low
jazzynico

Bug Description

"Measure path" aborts with dialog error:

Traceback (most recent call last):
  File "measure.py", line 270, in <module>
    e.affect()
  File "/usr/share/inkscape/extensions/inkex.py", line 268, in affect
    self.effect()
  File "measure.py", line 185, in effect
    [viewx, viewy, vieww, viewh] = doc.get('viewBox').split(' ')
ValueError: too many values to unpack

How to reproduce: select a path, invoke extension, either click Apply or enable
live preview.

Environment: Fedora 24, Inkscape 0.91 r13725, python 2.7.12-6

Quick fix: at line 185 of measure.py, insert ".trim()" before ".split".

Martin Owens (doctormo) wrote :

I recommend this change:

- [viewx, viewy, vieww, viewh] = doc.get('viewBox').split(' ')
+ (viewx, viewy, vieww, viewh) = doc.get('viewBox').strip().split(' ', 4)

Carlos (cafuruti) wrote :

Yes, that's better.

jazzynico (jazzynico) on 2016-11-13
tags: added: extensions-plugins
jazzynico (jazzynico) wrote :

Not reproduced on Windows XP and Xubuntu 16.04, lp:inkscape/0.92.x rev. 12183.

Does it occur with a specific document (if so, please attach and example SVG file) or with a blank new one? As far as I can tell, viewBoxes generated by Inkscape should not trigger that kind of error.

Note to devs: according to the SVG specs (https://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute):
"The value of the ‘viewBox’ attribute is a list of four numbers <min-x>, <min-y>, <width> and <height>, separated by whitespace and/or a comma..."
So I guess that we should also handle the comma correctly.

jazzynico (jazzynico) wrote :

What about the following patch (using regexp to handle inner whitespaces and commas)?

Tested on Windows XP with lp:inkscape/0.92.x rev. 15183.

Changed in inkscape:
importance: Undecided → Low
milestone: none → 0.93
status: New → In Progress
Carlos (cafuruti) wrote :

I've not tested 0.92. In my 0.91, the extension works ok with a trivial
path created in a new document. The error happened with an existing
document with a trailing blank in viewBox, which causes split() to return
one extra element. I didn't check the SVG spec whether trailing or other
extra blanks are legal, but either Inkscape should be more rigorous when
loading a file (either complaining or stripping), or the extension
should be more robust with split().

jazzynico (jazzynico) on 2016-11-25
Changed in inkscape:
assignee: nobody → jazzynico (jazzynico)
milestone: 0.93 → 0.92
jazzynico (jazzynico) wrote :

Fixed in lp:inkscape/0.92.x rev. 15226 and lp:inkscape rev. 15281.

Changed in inkscape:
status: In Progress → Fix Committed
Bryce Harrington (bryce) on 2017-01-10
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers