From f0edc6efd725aaf654bf1acbfc487d948941f191 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Fri, 11 Dec 2020 22:39:56 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20crash=20when=20use=20tags=20ref?= =?UTF-8?q?erence=20unknown=20tags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #303. --- cairosvg/defs.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cairosvg/defs.py b/cairosvg/defs.py index f65bbeeb..98533270 100644 --- a/cairosvg/defs.py +++ b/cairosvg/defs.py @@ -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()