changeset 2585:0112c1f7dcf0

plugin XEP-0050: filter form received from form-processing entity, to only keep "form" and "result" types
author Goffi <goffi@goffi.org>
date Fri, 11 May 2018 18:20:39 +0200
parents f8e4d855001e
children 57c8c155192f
files sat/plugins/plugin_xep_0050.py
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0050.py	Fri May 11 18:18:06 2018 +0200
+++ b/sat/plugins/plugin_xep_0050.py	Fri May 11 18:20:39 2018 +0200
@@ -299,9 +299,11 @@
         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]