From 063a7d33ffdc5a740df7212d2ed5e942e45d59e3 Mon Sep 17 00:00:00 2001 From: Malthe Borch Date: Tue, 5 Feb 2019 17:15:32 +0100 Subject: [PATCH] If the referenced url starts with '#' and no URL is given, use root parent's tree --- cairosvg/parser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cairosvg/parser.py b/cairosvg/parser.py index 4b394062..e27cd62f 100644 --- a/cairosvg/parser.py +++ b/cairosvg/parser.py @@ -383,7 +383,9 @@ def __init__(self, **kwargs): else: raise TypeError( 'No input. Use one of bytestring, file_obj or url.') - if parent and self.url == parent.url: + if parent and ( + self.url == parent.url or + (url.startswith('#') and not self.url)): root_parent = parent while root_parent.parent: root_parent = root_parent.parent