scour fails on some polygons/polylines

Bug #804238 reported by Hungerburg
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Low
jazzynico
Scour
Fix Released
Medium
Unassigned

Bug Description

This fragment in an svg file will break scour:

<polygon points="-125,-75 -125,125 75,125 75,-75"/>.

Traceback reads:

scour 0.26
Copyright Jeff Schiller, Louis Simard, 2010
Traceback (most recent call last):
  File "scour/scour.py", line 3183, in <module>
    out_string = scourString(in_string, options).encode("UTF-8")
  File "scour/scour.py", line 2952, in scourString
    cleanPolygon(polygon, options)
  File "scour/scour.py", line 2164, in cleanPolygon
    pts = parseListOfPoints(elem.getAttribute('points'))
  File "scour/scour.py", line 2136, in parseListOfPoints
    prev = nums[len(nums)-1]
IndexError: list index out of range

The Reason being, I suppose, that the list of points starts with a negative one.
I worked around with below patch, handle with care:

--- scour/scour-orig.py 2011-07-01 12:19:14.662878583 +0200
+++ scour/scour.py 2011-07-01 12:20:03.402875383 +0200
@@ -2129,6 +2129,9 @@
     if j == 0:
      if negcoords[0] != '':
       nums.append(negcoords[0])
+ # this could be the first point
+ elif len(nums) == 0:
+ nums.append( '-'+negcoords[j] )
     # otherwise all other strings will be negative
     else:
      # unless we accidentally split a number that was in scientific notation

Revision history for this message
Hungerburg (pch-myzel) wrote :
Revision history for this message
Louis Simard (louis-simard-deactivatedaccount) wrote :

Fixed in Scour revision 216. Thanks for your patch!

Changed in scour:
importance: Undecided → Medium
status: New → Fix Committed
jazzynico (jazzynico)
Changed in inkscape:
assignee: nobody → JazzyNico (jazzynico)
importance: Undecided → Low
milestone: none → 0.49
status: New → In Progress
Revision history for this message
jazzynico (jazzynico) wrote :

Fixed in Inkscape, revision 10785.

Changed in inkscape:
status: In Progress → Fix Committed
jazzynico (jazzynico)
Changed in inkscape:
status: Fix Committed → Fix Released
Changed in scour:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.