Skip to content

Commit

Permalink
Fixes #71 -- Prevent crash with empty paths
Browse files Browse the repository at this point in the history
  • Loading branch information
claudep committed Feb 2, 2017
1 parent 721d7b4 commit 92d7aa8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions svglib/svglib.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,8 @@ def convertText(self, node):

def convertPath(self, node):
d = node.getAttribute('d')
if not d:
return None
normPath = normalise_svg_path(d)
path = Path()
points = path.points
Expand Down
6 changes: 6 additions & 0 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ def test_unclosed_paths(self):
assert unclosed_path.operators == [
_MOVETO, _LINETO, _LINETO, _MOVETO, _LINETO]

def test_empty_path(self):
converter = svglib.Svg2RlgShapeConverter(None)
node = svglib.NodeTracker(etree.XML('<path id="W"/>'))
group = converter.convertPath(node)
assert group is None


class TestColorAttrConverter(object):
"Testing color attribute conversion."
Expand Down

0 comments on commit 92d7aa8

Please sign in to comment.