From 29907dc379789069468e1b7d20bd0930b3e54695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Mon, 26 Feb 2024 20:36:03 +0100 Subject: [PATCH] fix: Exception when unable to identify favicon mimetype --- lookyloo/lookyloo.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lookyloo/lookyloo.py b/lookyloo/lookyloo.py index 022f1ca0..f92439e1 100644 --- a/lookyloo/lookyloo.py +++ b/lookyloo/lookyloo.py @@ -34,7 +34,7 @@ from lacuscore import (LacusCore, CaptureSettings as CaptureSettingsCore) from PIL import Image, UnidentifiedImageError from playwrightcapture import get_devices -from puremagic import from_string # type: ignore[import-untyped] +from puremagic import from_string, PureError # type: ignore[import-untyped] from pylacus import (PyLacus, CaptureStatus as CaptureStatusPy # CaptureResponse as CaptureResponsePy, @@ -867,8 +867,12 @@ class Lookyloo(): favicon = fav.getvalue() if not favicon: return '', '' - mimetype = from_string(favicon, mime=True) - return mimetype, base64.b64encode(favicon).decode() + try: + mimetype = from_string(favicon, mime=True) + return mimetype, base64.b64encode(favicon).decode() + except PureError: + self.logger.warning(f'Unable to get the mimetype of the favicon for {capture_uuid}.') + return '', '' return fav def get_html(self, capture_uuid: str, /, all_html: bool=False) -> BytesIO: