Skip to content

Commit

Permalink
Avoid endless loops when updating def attributes
Browse files Browse the repository at this point in the history
Fix #413.
  • Loading branch information
liZe committed Feb 13, 2024
1 parent cf0c406 commit 051df1b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cairosvg/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@
}


def update_def_href(surface, def_name, def_dict):
def update_def_href(surface, def_name, def_dict, chain=None):
"""Update the attributes of the def according to its href attribute."""
def_node = def_dict[def_name]
href = parse_url(def_node.get_href()).fragment
if href in def_dict:
update_def_href(surface, href, def_dict)
if chain is None:
chain = set()
if href in def_dict and href not in chain:
chain.add(href)
update_def_href(surface, href, def_dict, chain)
href_node = def_dict[href]
def_dict[def_name] = Tree(
url=f'#{def_name}', url_fetcher=def_node.url_fetcher,
Expand Down

0 comments on commit 051df1b

Please sign in to comment.