From da147c5cc7c00637fcb4e487acb491a875399360 Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 11 May 2018 18:20:39 +0200 Subject: [PATCH] plugin XEP-0050: filter form received from form-processing entity, to only keep "form" and "result" types --- sat/plugins/plugin_xep_0050.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sat/plugins/plugin_xep_0050.py b/sat/plugins/plugin_xep_0050.py index 8017e981..71ab0536 100644 --- a/sat/plugins/plugin_xep_0050.py +++ b/sat/plugins/plugin_xep_0050.py @@ -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]