Philipp Hörist pushed to branch ogp-image-preview at gajim / gajim
Commits:
e207952a by Philipp Hörist at 2026-02-22T22:36:55+01:00
Fix a few things
- - - - -
3 changed files:
- gajim/common/modules/message_util.py
- gajim/common/multiprocess/url_preview.py
- gajim/gtk/preview/open_graph.py
Changes:
=====================================
gajim/common/modules/message_util.py
=====================================
@@ -268,6 +268,12 @@ def _parse() -> tuple[str, bytes]:
if not image_bytes:
raise ValueError
+ if not datauri.media_type not in ("image/png", "image/jpeg"):
+ raise ValueError
+
+ if len(image_bytes) > 50_000:
+ raise ValueError
+
return datauri.media_type, image_bytes
try:
=====================================
gajim/common/multiprocess/url_preview.py
=====================================
@@ -61,5 +61,5 @@ def _make_thumbnail(content: bytes) -> OpenGraphThumbnail:
image = Image.open(io.BytesIO(content))
image.thumbnail((THUMBNAIL_SIZE, THUMBNAIL_SIZE))
thumbnail = io.BytesIO()
- image.save(thumbnail, format="PNG")
+ image.save(thumbnail, format="PNG", optimize=True)
return OpenGraphThumbnail.from_bytes(thumbnail.getvalue())
=====================================
gajim/gtk/preview/open_graph.py
=====================================
@@ -92,7 +92,7 @@ def set_open_graph(self, og_data: OpenGraphData | None, *,
minimal: bool) -> Non
if description := og_data.description:
if len(description) > 100:
-
self._description_label.set_text(f"{to_one_line(description)[:100]}...")
+
self._description_label.set_text(f"{to_one_line(description)[:100]}…")
self._description_label.set_tooltip_text(description)
else:
self._description_label.set_text(to_one_line(description))
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/e207952af2b58ac1aad38d9a452e37a2228a4c78
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/e207952af2b58ac1aad38d9a452e37a2228a4c78
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]