Print malformed pubsub avatar stanzas

This commit is contained in:
Philipp Hörist 2017-10-08 14:32:59 +02:00
parent 1b90f75b17
commit 1d5665632a
1 changed files with 6 additions and 0 deletions

View File

@ -584,14 +584,20 @@ class PubsubAvatarReceivedEvent(nec.NetworkIncomingEvent):
if self.items_node.getAttr('node') != 'urn:xmpp:avatar:data': if self.items_node.getAttr('node') != 'urn:xmpp:avatar:data':
return return
item = self.items_node.getTag('item') item = self.items_node.getTag('item')
if not item:
log.warning('Received malformed avatar data via pubsub')
log.warning(self.stanza)
return
self.sha = item.getAttr('id') self.sha = item.getAttr('id')
data_tag = item.getTag('data', namespace='urn:xmpp:avatar:data') data_tag = item.getTag('data', namespace='urn:xmpp:avatar:data')
if self.sha is None or data_tag is None: if self.sha is None or data_tag is None:
log.warning('Received malformed avatar data via pubsub') log.warning('Received malformed avatar data via pubsub')
log.warning(self.stanza)
return return
self.data = data_tag.getData() self.data = data_tag.getData()
if self.data is None: if self.data is None:
log.warning('Received malformed avatar data via pubsub') log.warning('Received malformed avatar data via pubsub')
log.warning(self.stanza)
return return
self.data = base64.b64decode(self.data.encode('utf-8')) self.data = base64.b64decode(self.data.encode('utf-8'))