From 2270a9b3c9f06988d778b4c19e716b2609d5e918 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub <guillaume@courtbouillon.org> Date: Tue, 3 Dec 2024 17:06:42 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20crash=20with=20SVG=20symbols?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #2316. --- tests/draw/svg/test_defs.py | 9 ++++++--- weasyprint/svg/__init__.py | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/draw/svg/test_defs.py b/tests/draw/svg/test_defs.py index 358677953..3cb3965ae 100644 --- a/tests/draw/svg/test_defs.py +++ b/tests/draw/svg/test_defs.py @@ -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> ''' @@ -19,8 +22,8 @@ RRRRR_____ RRRRR_____ __________ - ___RRRRR__ - ___RRRRR__ + ___BB_____ + ___BB_____ __________ _____RRRRR _____RRRRR diff --git a/weasyprint/svg/__init__.py b/weasyprint/svg/__init__.py index 9fb96af84..f29eb89ad 100644 --- a/weasyprint/svg/__init__.py +++ b/weasyprint/svg/__init__.py @@ -336,6 +336,7 @@ def __init__(self, tree, url): self.masks = {} self.patterns = {} self.paths = {} + self.symbols = {} self.use_cache = {}