More caps cleanup

This commit is contained in:
Lance Stout 2013-02-11 20:01:53 -08:00
parent cdeae7e72f
commit 99ecb166d3

View File

@ -207,29 +207,32 @@ class XEP_0115(BasePlugin):
form_types = [] form_types = []
deduped_form_types = set() deduped_form_types = set()
for stanza in caps['substanzas']: for stanza in caps['substanzas']:
if isinstance(stanza, self.xmpp['xep_0004'].stanza.Form): if not isinstance(stanza, self.xmpp['xep_0004'].stanza.Form):
if 'FORM_TYPE' in stanza['fields']: log.debug("Non form extension found, ignoring for caps")
f_type = tuple(stanza['fields']['FORM_TYPE']['value']) caps.xml.remove(stanza.xml)
form_types.append(f_type) continue
deduped_form_types.add(f_type) if 'FORM_TYPE' in stanza['fields']:
if len(form_types) != len(deduped_form_types): f_type = tuple(stanza['fields']['FORM_TYPE']['value'])
log.debug("Duplicated FORM_TYPE values, " + \ form_types.append(f_type)
"invalid for caps") deduped_form_types.add(f_type)
if len(form_types) != len(deduped_form_types):
log.debug("Duplicated FORM_TYPE values, " + \
"invalid for caps")
return False
if len(f_type) > 1:
deduped_type = set(f_type)
if len(f_type) != len(deduped_type):
log.debug("Extra FORM_TYPE data, invalid for caps")
return False return False
if len(f_type) > 1: if stanza['fields']['FORM_TYPE']['type'] != 'hidden':
deduped_type = set(f_type) log.debug("Field FORM_TYPE type not 'hidden', " + \
if len(f_type) != len(deduped_type): "ignoring form for caps")
log.debug("Extra FORM_TYPE data, invalid for caps")
return False
if stanza['fields']['FORM_TYPE']['type'] != 'hidden':
log.debug("Field FORM_TYPE type not 'hidden', " + \
"ignoring form for caps")
caps.xml.remove(stanza.xml)
else:
log.debug("No FORM_TYPE found, ignoring form for caps")
caps.xml.remove(stanza.xml) caps.xml.remove(stanza.xml)
else:
log.debug("No FORM_TYPE found, ignoring form for caps")
caps.xml.remove(stanza.xml)
verstring = self.generate_verstring(caps, hash) verstring = self.generate_verstring(caps, hash)
if verstring != check_verstring: if verstring != check_verstring: