plugin XEP-0050: filter form received from form-processing entity, to only keep "form" and "result" types

This commit is contained in:
Goffi 2018-05-11 18:20:39 +02:00
commit da147c5cc7

View file

@ -299,9 +299,11 @@ class XEP_0050(object):
for note_elt in command_elt.elements(NS_COMMANDS, 'note'):
notes.append((self._getDataLvl(note_elt.getAttribute('type', 'info')),
unicode(note_elt)))
try:
data_elt = command_elt.elements(data_form.NS_X_DATA, 'x').next()
except StopIteration:
for data_elt in command_elt.elements(data_form.NS_X_DATA, 'x'):
if data_elt['type'] in ('form', 'result'):
break
else:
# no matching data element found
if status != XEP_0050.STATUS.COMPLETED:
log.warning(_("No known payload found in ad-hoc command result, aborting"))
del self.requesting[session_id]