From 812e1946ec308eedf6866877186adc392785caf7 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Tue, 13 Feb 2024 22:36:45 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20crash=20when=20rendering=20SVGs?= =?UTF-8?q?=20with=20non-text=20a=20children?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related to #2030. Fix #2070. --- weasyprint/svg/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/weasyprint/svg/__init__.py b/weasyprint/svg/__init__.py index fc911cca7..2e06fa5ba 100644 --- a/weasyprint/svg/__init__.py +++ b/weasyprint/svg/__init__.py @@ -464,7 +464,11 @@ def draw_node(self, node, font_size, fill_stroke=True): if node.display and node.tag not in DEF_TYPES: for child in node: self.draw_node(child, font_size, fill_stroke) - if TAGS.get(node.tag) == text and child.visible: + visible_text_child = ( + TAGS.get(node.tag) == text and + TAGS.get(child.tag) == text and + child.visible) + if visible_text_child: if not is_valid_bounding_box(child.text_bounding_box): continue x1, y1 = child.text_bounding_box[:2]