Skip to content

Commit

Permalink
Guard against empty style tags
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanw authored and claudep committed Mar 16, 2022
1 parent 42d0a54 commit 999a964
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion svglib/svglib.py
Original file line number Diff line number Diff line change
@@ -868,7 +868,7 @@ def renderG(self, node, clipping=None, display=1):
return gr

def renderStyle(self, node):
self.attrConverter.css_rules = CSSMatcher(node.text)
self.attrConverter.css_rules = CSSMatcher(node.text or "")

def renderSymbol(self, node):
return self.renderG(node, display=0)
1 change: 1 addition & 0 deletions tests/samples/others/empty_style.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions tests/test_samples.py
Original file line number Diff line number Diff line change
@@ -443,3 +443,7 @@ def test_em_unit_svg(self):
path = join(TEST_ROOT, "samples", "others", "em_unit.svg")
drawing = svglib.svg2rlg(path)
assert drawing.contents[0].transform[5] == svglib.DEFAULT_FONT_SIZE

def test_empty_style(self):
path = join(TEST_ROOT, "samples", "others", "empty_style.svg")
svglib.svg2rlg(path)

0 comments on commit 999a964

Please sign in to comment.