From 40fcd404a4d5c208075ced804ceabf01746d4067 Mon Sep 17 00:00:00 2001 From: Alexander PapaTutuWawa Date: Fri, 5 Nov 2021 22:24:11 +0100 Subject: [PATCH] avatar: Guard against a non-specified type --- xmpp_discord_bridge/avatar.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xmpp_discord_bridge/avatar.py b/xmpp_discord_bridge/avatar.py index a9db00f..68cf949 100644 --- a/xmpp_discord_bridge/avatar.py +++ b/xmpp_discord_bridge/avatar.py @@ -20,8 +20,13 @@ class AvatarManager: self._logger = logging.getLogger("xmpp.avatar") def _save_avatar(self, jid, data, type_): - self._logger.debug("Got type_ of '%s'", type_) + if not type_: + # TODO: Maybe guess? + self._logger.info("Got VCARD with empty photo type. Assuming image/png") + type_ = "image/png" + if len(type_.split("/")) < 2: + self._logger.debug("Got type_ of '%s'", type_) self._logger.debug("COMPAT! Just assuming image/png") type_ = "image/png" filename = hashlib.sha1(data).hexdigest() + "." + type_.split("/")[1]