Skip to content

Commit

Permalink
Don’t crash when SVG file can’t be rendered
Browse files Browse the repository at this point in the history
Related to #2070.
  • Loading branch information
liZe committed Feb 13, 2024
1 parent 50e9eb6 commit b6d07b8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions weasyprint/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,12 @@ def get_intrinsic_size(self, image_resolution, font_size):
return width, height, ratio

def draw(self, stream, concrete_width, concrete_height, image_rendering):
self._svg.draw(
stream, concrete_width, concrete_height, self._base_url,
self._url_fetcher, self._context)
try:
self._svg.draw(
stream, concrete_width, concrete_height, self._base_url,
self._url_fetcher, self._context)
except BaseException:
LOGGER.error('Failed to render SVG image %s', self._base_url)


def get_image_from_uri(cache, url_fetcher, options, url, forced_mime_type=None,
Expand Down

0 comments on commit b6d07b8

Please sign in to comment.