Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
ce11ba7d by Philipp Hörist at 2026-08-12T00:24:11+02:00
fix: VCardTemp: Guard against base64 decoding errors
- - - - -
1 changed file:
- nbxmpp/modules/vcard_temp.py
Changes:
=====================================
nbxmpp/modules/vcard_temp.py
=====================================
@@ -9,6 +9,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING
import hashlib
+import logging
from dataclasses import dataclass
from dataclasses import field
@@ -28,6 +29,9 @@ if TYPE_CHECKING:
from nbxmpp.client import Client
+log = logging.getLogger("nbxmpp.m.vcardtemp")
+
+
class VCardTemp(BaseModule):
def __init__(self, client: Client) -> None:
BaseModule.__init__(self, client)
@@ -135,6 +139,11 @@ class VCard:
if not avatar:
return None, None
- encoded_avatar = b64decode(avatar)
- avatar_sha = hashlib.sha1(encoded_avatar).hexdigest()
- return encoded_avatar, avatar_sha
+ try:
+ decoded_avatar = b64decode(avatar)
+ except Exception as error:
+ log.warning("Unable to decode avatar: %s", error)
+ return None, None
+
+ avatar_sha = hashlib.sha1(decoded_avatar).hexdigest()
+ return decoded_avatar, avatar_sha
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/-/commit/ce11ba7dc67a478449778680e58723cbecf7121d
--
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/-/commit/ce11ba7dc67a478449778680e58723cbecf7121d
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]