prevent traceback when server doen't include a query in jabber:iq:roster reply. Fixes #4579

This commit is contained in:
Yann Leboulanger 2008-12-15 15:32:59 +00:00
parent 5c8cd8839a
commit 24bb239fdb
1 changed files with 15 additions and 13 deletions

View File

@ -68,19 +68,21 @@ class Roster(PlugIn):
if not sender is None and not sender.bareMatch( if not sender is None and not sender.bareMatch(
self._owner.User + '@' + self._owner.Server): self._owner.User + '@' + self._owner.Server):
return return
for item in stanza.getTag('query').getTags('item'): query = stanza.getTag('query')
jid=item.getAttr('jid') if query:
if item.getAttr('subscription')=='remove': for item in query.getTags('item'):
if jid in self._data: del self._data[jid] jid=item.getAttr('jid')
return if item.getAttr('subscription')=='remove':
self.DEBUG('Setting roster item %s...'%jid,'ok') if jid in self._data: del self._data[jid]
if jid not in self._data: self._data[jid]={} return
self._data[jid]['name']=item.getAttr('name') self.DEBUG('Setting roster item %s...'%jid,'ok')
self._data[jid]['ask']=item.getAttr('ask') if jid not in self._data: self._data[jid]={}
self._data[jid]['subscription']=item.getAttr('subscription') self._data[jid]['name']=item.getAttr('name')
self._data[jid]['groups']=[] self._data[jid]['ask']=item.getAttr('ask')
if 'resources' not in self._data[jid]: self._data[jid]['resources']={} self._data[jid]['subscription']=item.getAttr('subscription')
for group in item.getTags('group'): self._data[jid]['groups'].append(group.getData()) 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._data[self._owner.User+'@'+self._owner.Server]={'resources':{},'name':None,'ask':None,'subscription':None,'groups':None,}
self.set=1 self.set=1