diff --git a/cairosvg/defs.py b/cairosvg/defs.py index 2229089e..dd49e2cb 100644 --- a/cairosvg/defs.py +++ b/cairosvg/defs.py @@ -359,7 +359,15 @@ def use(surface, node): del node['viewBox'] if 'mask' in node: del node['mask'] - href = parse_url(node.get('{http://www.w3.org/1999/xlink}href')).geturl() + + # the href attr should be in the xlink namespace, + # but some libs do not respect this + href = node.get('{http://www.w3.org/1999/xlink}href') or node.get('href') + href = parse_url(href).geturl() + + if not href: + raise ValueError('Invalid tag: {!r}'.format(node)) + tree = Tree( url=href, url_fetcher=node.url_fetcher, parent=node, tree_cache=surface.tree_cache, unsafe=node.unsafe)