Skip to content

Commit f0edc6e

Browse files
committed
Don’t crash when use tags reference unknown tags
Fix #303.
1 parent 73349a7 commit f0edc6e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cairosvg/defs.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,13 @@ def use(surface, node):
346346
if 'mask' in node:
347347
del node['mask']
348348
href = parse_url(node.get_href()).geturl()
349-
tree = Tree(
350-
url=href, url_fetcher=node.url_fetcher, parent=node,
351-
tree_cache=surface.tree_cache, unsafe=node.unsafe)
349+
try:
350+
tree = Tree(
351+
url=href, url_fetcher=node.url_fetcher, parent=node,
352+
tree_cache=surface.tree_cache, unsafe=node.unsafe)
353+
except TypeError:
354+
surface.context.restore()
355+
return
352356

353357
if not match_features(tree.xml_tree):
354358
surface.context.restore()

0 commit comments

Comments
 (0)