Skip to content

Commit

Permalink
fix: Exception when unable to identify favicon mimetype
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Feb 26, 2024
1 parent b76d28d commit 29907dc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lookyloo/lookyloo.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
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,
Expand Down Expand Up @@ -867,8 +867,12 @@ def get_potential_favicons(self, capture_uuid: str, /, all_favicons: bool=False,
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:
Expand Down

0 comments on commit 29907dc

Please sign in to comment.