getposinlayer fails if height attribute is missing

Bug #1461346 reported by Thomas Holder on 2015-06-03
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Medium
Aurium

Bug Description

Inkscape 0.91 on Gentoo Linux.

When loading an SVG file which has no root node "height" attribute, then all inkex derived extensions fail in getposinlayer.

Instructions to reproduce:

1) Open Inkscape
2) Save new SVG file
3) Open file with text editor, remove <svg height="..."> attribute.
4) Load into Inkscape again
5) Run any extension, for example draw a path and do "Extensions > Modify Path > Add Nodes..."

Result:

Traceback (most recent call last):
  File "addnodes.py", line 113, in <module>
    e.affect()
  File "/usr/share/inkscape/extensions/inkex.py", line 265, in affect
    self.getposinlayer()
  File "/usr/share/inkscape/extensions/inkex.py", line 209, in getposinlayer
    doc_height = self.unittouu(self.document.getroot().get('height'))
  File "/usr/share/inkscape/extensions/inkex.py", line 343, in unittouu
    p = param.match(string)
TypeError: expected string or buffer

Related branches

Thomas Holder (speleo3) wrote :
su_v (suv-lp) on 2015-06-03
tags: added: extensions-plugins
su_v (suv-lp) wrote :

On OS X 10.7.5:
- not reproduced with Inkscape 0.48.5
- reproduced with 0.91 r13725 and 0.91+devel r14192

Changed in inkscape:
importance: Undecided → Medium
milestone: none → 0.92
status: New → Confirmed
tags: added: regression
su_v (suv-lp) wrote :

With stable Inkscape 0.91, the proposed patch
- works as expected for SVG files which only omit 'height', but define 'width' for the root <svg> node.
- does not help for earlier failure (to determine 'x') with SVG files which omit either only 'width' or both attributes (width, height), but define a viewBox attribute.

It seems more likely to me that third-party SVG files omit both attributes, rather than define only 'width' but not 'height' -> inkex.py eventually should handle all cases.

Not that with current trunk (which at the moment always and unconditionally adds a viewBox attribute if not defined, and in that case also any missing 'width' or 'height' attribute), the tests might differ for cases which originally do not define a viewBox attribute.

su_v (suv-lp) wrote :

On 2015-06-03 04:59 (+0200), ~suv wrote:
> - does not help for earlier failure (to determine 'x') with SVG files
> which omit either only 'width' or both attributes (width, height),
> but define a viewBox attribute.

Reported separately in
* Bug #1463623 “Error trying to save Optimized SVG”
  https://bugs.launchpad.net/inkscape/+bug/1463623

su_v (suv-lp) wrote :

Variation of proposed fix attached (it does not assume '0' for missing (undefined) attribute 'height', but adds checks if the retrieved value is 'None'). Please review and test (best in combination with patch for bug #1463623).

su_v (suv-lp) on 2015-07-10
tags: added: backport-proposed
jazzynico (jazzynico) wrote :

Patch tested successfully on Windows XP (32 bit), with Inkscape trunk rev. 14237.

Changed in inkscape:
assignee: nobody → ~suv (suv-lp)
status: Confirmed → In Progress
su_v (suv-lp) wrote :

Fix committed to trunk in rev 14241.

Changed in inkscape:
status: In Progress → Fix Committed
su_v (suv-lp) wrote :

Fix backported to 0.91.x in rev 13805.

Changed in inkscape:
milestone: 0.92 → 0.91.1
tags: removed: backport-proposed
su_v (suv-lp) wrote :

Rev 14241 reverted in trunk - obsoleted by rev 14564.

TODO: revert rev 13805 in 0.91.x, and backport rev 14564 to 0.91.x.

Changed in inkscape:
assignee: ~suv (suv-lp) → Aurium (aurium)
milestone: 0.91.1 → 0.92
tags: added: backport-proposed
Martin Owens (doctormo) wrote :

Backport can't be applied to 0.92.

tags: removed: backport-proposed
Hachmann (marenhachmann) wrote :

Doesn't need to, works.

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