From 24bb239fdb5c9d9522ddaca33033f8553ca89786 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Mon, 15 Dec 2008 15:32:59 +0000 Subject: [PATCH] prevent traceback when server doen't include a query in jabber:iq:roster reply. Fixes #4579 --- src/common/xmpp/roster.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/common/xmpp/roster.py b/src/common/xmpp/roster.py index 8f151fc36..292b3ea8b 100644 --- a/src/common/xmpp/roster.py +++ b/src/common/xmpp/roster.py @@ -68,19 +68,21 @@ class Roster(PlugIn): if not sender is None and not sender.bareMatch( self._owner.User + '@' + self._owner.Server): return - for item in stanza.getTag('query').getTags('item'): - jid=item.getAttr('jid') - if item.getAttr('subscription')=='remove': - if jid in self._data: del self._data[jid] - return - self.DEBUG('Setting roster item %s...'%jid,'ok') - if jid not in self._data: self._data[jid]={} - self._data[jid]['name']=item.getAttr('name') - self._data[jid]['ask']=item.getAttr('ask') - self._data[jid]['subscription']=item.getAttr('subscription') - self._data[jid]['groups']=[] - if 'resources' not in self._data[jid]: self._data[jid]['resources']={} - for group in item.getTags('group'): self._data[jid]['groups'].append(group.getData()) + query = stanza.getTag('query') + if query: + for item in query.getTags('item'): + jid=item.getAttr('jid') + if item.getAttr('subscription')=='remove': + if jid in self._data: del self._data[jid] + return + self.DEBUG('Setting roster item %s...'%jid,'ok') + if jid not in self._data: self._data[jid]={} + self._data[jid]['name']=item.getAttr('name') + self._data[jid]['ask']=item.getAttr('ask') + self._data[jid]['subscription']=item.getAttr('subscription') + self._data[jid]['groups']=[] + if 'resources' not in self._data[jid]: self._data[jid]['resources']={} + for group in item.getTags('group'): self._data[jid]['groups'].append(group.getData()) self._data[self._owner.User+'@'+self._owner.Server]={'resources':{},'name':None,'ask':None,'subscription':None,'groups':None,} self.set=1