Skip to content

Commit

Permalink
Don’t crash when use tags reference unknown tags
Browse files Browse the repository at this point in the history
Fix #303.
  • Loading branch information
liZe committed Dec 11, 2020
1 parent 73349a7 commit f0edc6e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cairosvg/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,13 @@ def use(surface, node):
if 'mask' in node:
del node['mask']
href = parse_url(node.get_href()).geturl()
tree = Tree(
url=href, url_fetcher=node.url_fetcher, parent=node,
tree_cache=surface.tree_cache, unsafe=node.unsafe)
try:
tree = Tree(
url=href, url_fetcher=node.url_fetcher, parent=node,
tree_cache=surface.tree_cache, unsafe=node.unsafe)
except TypeError:
surface.context.restore()
return

if not match_features(tree.xml_tree):
surface.context.restore()
Expand Down

0 comments on commit f0edc6e

Please sign in to comment.