Skip to content

Commit 051df1b

Browse files
committed
Avoid endless loops when updating def attributes
Fix #413.
1 parent cf0c406 commit 051df1b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

cairosvg/defs.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@
2929
}
3030

3131

32-
def update_def_href(surface, def_name, def_dict):
32+
def update_def_href(surface, def_name, def_dict, chain=None):
3333
"""Update the attributes of the def according to its href attribute."""
3434
def_node = def_dict[def_name]
3535
href = parse_url(def_node.get_href()).fragment
36-
if href in def_dict:
37-
update_def_href(surface, href, def_dict)
36+
if chain is None:
37+
chain = set()
38+
if href in def_dict and href not in chain:
39+
chain.add(href)
40+
update_def_href(surface, href, def_dict, chain)
3841
href_node = def_dict[href]
3942
def_dict[def_name] = Tree(
4043
url=f'#{def_name}', url_fetcher=def_node.url_fetcher,

0 commit comments

Comments
 (0)