Skip to content

Commit

Permalink
Don’t crash with SVG symbols
Browse files Browse the repository at this point in the history
Fix #2316.
  • Loading branch information
liZe committed Dec 3, 2024
1 parent 89a6f44 commit 2270a9b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/draw/svg/test_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
<svg width="10px" height="10px" xmlns="http://www.w3.org/2000/svg">
<defs>
<rect id="rectangle" width="5" height="2" fill="red" />
<symbol id="square">
<rect width="2" height="2" fill="blue" />
</symbol>
</defs>
<use href="#rectangle" />
<use href="#rectangle" x="3" y="3" />
<use href="#square" x="3" y="3" />
<use href="#rectangle" x="5" y="6" />
</svg>
'''
Expand All @@ -19,8 +22,8 @@
RRRRR_____
RRRRR_____
__________
___RRRRR__
___RRRRR__
___BB_____
___BB_____
__________
_____RRRRR
_____RRRRR
Expand Down
1 change: 1 addition & 0 deletions weasyprint/svg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ def __init__(self, tree, url):
self.masks = {}
self.patterns = {}
self.paths = {}
self.symbols = {}

self.use_cache = {}

Expand Down

0 comments on commit 2270a9b

Please sign in to comment.