diff options
author | Lance Stout <lancestout@gmail.com> | 2012-07-30 19:44:13 -0700 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2012-07-30 19:44:13 -0700 |
commit | 3bd84b8d279a8b79f8e3bac4234c1e2e2c1d60fc (patch) | |
tree | 75ddea04d77be6f1fa57c7491bf3497920a2f7bd /sleekxmpp | |
parent | bc8b5774aca6de6f69676a1f0019a0d910c98427 (diff) | |
download | slixmpp-3bd84b8d279a8b79f8e3bac4234c1e2e2c1d60fc.tar.gz slixmpp-3bd84b8d279a8b79f8e3bac4234c1e2e2c1d60fc.tar.bz2 slixmpp-3bd84b8d279a8b79f8e3bac4234c1e2e2c1d60fc.tar.xz slixmpp-3bd84b8d279a8b79f8e3bac4234c1e2e2c1d60fc.zip |
Ignore roster updates with unrecognized subscription values.
Diffstat (limited to 'sleekxmpp')
-rw-r--r-- | sleekxmpp/clientxmpp.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sleekxmpp/clientxmpp.py b/sleekxmpp/clientxmpp.py index 7cdaa799..9aa64256 100644 --- a/sleekxmpp/clientxmpp.py +++ b/sleekxmpp/clientxmpp.py @@ -287,15 +287,17 @@ class ClientXMPP(BaseXMPP): if iq['roster']['ver']: roster.version = iq['roster']['ver'] items = iq['roster']['items'] - for jid in items: - item = items[jid] - roster[jid]['name'] = item['name'] - roster[jid]['groups'] = item['groups'] - roster[jid]['from'] = item['subscription'] in ['from', 'both'] - roster[jid]['to'] = item['subscription'] in ['to', 'both'] - roster[jid]['pending_out'] = (item['ask'] == 'subscribe') - - roster[jid].save(remove=(item['subscription'] == 'remove')) + + valid_subscriptions = ('to', 'from', 'both', 'none', 'remove') + for jid, item in items.items(): + if item['subscription'] in valid_subscriptions: + roster[jid]['name'] = item['name'] + roster[jid]['groups'] = item['groups'] + roster[jid]['from'] = item['subscription'] in ('from', 'both') + roster[jid]['to'] = item['subscription'] in ('to', 'both') + roster[jid]['pending_out'] = (item['ask'] == 'subscribe') + + roster[jid].save(remove=(item['subscription'] == 'remove')) self.event("roster_update", iq) if iq['type'] == 'set': |