changeset 3859:3ef988734869

core: fix calls to `domish.Element.elements`: domish.Element.elements should be called with namespace and element name as 2 arguments, but it has been confused in several places with the call to `domish.Element.addElement` which is often done with a `(namespace, name)` tuple. Unfortunately calling with a tuple is accepted and doesn't raise any error in `elements`, but this result in a wrong element returned. This patch fixes the erroneous calls.
author Goffi <goffi@goffi.org>
date Wed, 20 Jul 2022 17:12:29 +0200
parents 6e785662dd7d
children e417c478b488
files sat/plugins/plugin_comp_file_sharing.py sat/plugins/plugin_exp_invitation.py sat/plugins/plugin_misc_attach.py sat/plugins/plugin_sec_aesgcm.py sat/plugins/plugin_xep_0060.py sat/plugins/plugin_xep_0234.py sat/plugins/plugin_xep_0346.py
diffstat 7 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_comp_file_sharing.py	Thu Jul 14 12:55:30 2022 +0200
+++ b/sat/plugins/plugin_comp_file_sharing.py	Wed Jul 20 17:12:29 2022 +0200
@@ -731,7 +731,7 @@
     def _getDirectoryMetadataElts(
             self, client, elt, file_data):
         try:
-            affiliation_elt = next(elt.elements((NS_FS_AFFILIATION, "affiliation")))
+            affiliation_elt = next(elt.elements(NS_FS_AFFILIATION, "affiliation"))
         except StopIteration:
             pass
         else:
--- a/sat/plugins/plugin_exp_invitation.py	Thu Jul 14 12:55:30 2022 +0200
+++ b/sat/plugins/plugin_exp_invitation.py	Wed Jul 20 17:12:29 2022 +0200
@@ -268,7 +268,7 @@
             args = [service, node, item_id, item_elt]
         else:
             try:
-                node_data_elt = next(pubsub_elt.elements((NS_INVITATION, "node_data")))
+                node_data_elt = next(pubsub_elt.elements(NS_INVITATION, "node_data"))
             except StopIteration:
                 raise exceptions.DataError("Bad invitation, ignoring")
             namespace = node_data_elt['namespace']
--- a/sat/plugins/plugin_misc_attach.py	Thu Jul 14 12:55:30 2022 +0200
+++ b/sat/plugins/plugin_misc_attach.py	Wed Jul 20 17:12:29 2022 +0200
@@ -248,7 +248,7 @@
     async def defaultAttach(self, client, data):
         await self.uploadFiles(client, data)
         # TODO: handle xhtml-im
-        body_elt = next(data["xml"].elements((C.NS_CLIENT, "body")))
+        body_elt = next(data["xml"].elements(C.NS_CLIENT, "body"))
         attachments = data["extra"][C.MESS_KEY_ATTACHMENTS]
         if attachments:
             body_links = '\n'.join(a['url'] for a in attachments)
--- a/sat/plugins/plugin_sec_aesgcm.py	Thu Jul 14 12:55:30 2022 +0200
+++ b/sat/plugins/plugin_sec_aesgcm.py	Wed Jul 20 17:12:29 2022 +0200
@@ -167,7 +167,7 @@
             attachments.clear()
             del data["extra"][C.MESS_KEY_ATTACHMENTS]
 
-        body_elt = next(data["xml"].elements((C.NS_CLIENT, "body")))
+        body_elt = next(data["xml"].elements(C.NS_CLIENT, "body"))
 
         for attachment in attachments:
             body_elt.addContent(attachment["url"])
--- a/sat/plugins/plugin_xep_0060.py	Thu Jul 14 12:55:30 2022 +0200
+++ b/sat/plugins/plugin_xep_0060.py	Wed Jul 20 17:12:29 2022 +0200
@@ -966,7 +966,7 @@
         def cb(iq_elt):
             try:
                 affiliations_elt = next(
-                    iq_elt.pubsub.elements((pubsub.NS_PUBSUB, "affiliations"))
+                    iq_elt.pubsub.elements(pubsub.NS_PUBSUB, "affiliations")
                 )
             except StopIteration:
                 raise ValueError(
@@ -977,7 +977,7 @@
             try:
                 return {
                     e["node"]: e["affiliation"]
-                    for e in affiliations_elt.elements((pubsub.NS_PUBSUB, "affiliation"))
+                    for e in affiliations_elt.elements(pubsub.NS_PUBSUB, "affiliation")
                 }
             except KeyError:
                 raise ValueError(
@@ -1009,7 +1009,7 @@
         def cb(iq_elt):
             try:
                 affiliations_elt = next(
-                    iq_elt.pubsub.elements((pubsub.NS_PUBSUB_OWNER, "affiliations"))
+                    iq_elt.pubsub.elements(pubsub.NS_PUBSUB_OWNER, "affiliations")
                 )
             except StopIteration:
                 raise ValueError(
@@ -1402,7 +1402,7 @@
         iq_elt = await request.send(client.xmlstream)
         try:
             subscriptions_elt = next(
-                iq_elt.pubsub.elements((pubsub.NS_PUBSUB, "subscriptions"))
+                iq_elt.pubsub.elements(pubsub.NS_PUBSUB, "subscriptions")
             )
         except StopIteration:
             raise ValueError(
--- a/sat/plugins/plugin_xep_0234.py	Thu Jul 14 12:55:30 2022 +0200
+++ b/sat/plugins/plugin_xep_0234.py	Wed Jul 20 17:12:29 2022 +0200
@@ -667,7 +667,7 @@
                     return
                 file_data = content_data["application_data"]["file_data"]
                 try:
-                    file_elt = next(elt.elements((NS_JINGLE_FT, "file")))
+                    file_elt = next(elt.elements(NS_JINGLE_FT, "file"))
                 except StopIteration:
                     raise exceptions.DataError
                 algo, file_data["given_file_hash"] = self._hash.parseHashElt(file_elt)
--- a/sat/plugins/plugin_xep_0346.py	Thu Jul 14 12:55:30 2022 +0200
+++ b/sat/plugins/plugin_xep_0346.py	Wed Jul 20 17:12:29 2022 +0200
@@ -372,7 +372,7 @@
         items, metadata = items_data
         items_xmlui = []
         for item_elt in items:
-            for x_elt in item_elt.elements((data_form.NS_X_DATA, "x")):
+            for x_elt in item_elt.elements(data_form.NS_X_DATA, "x"):
                 form = data_form.Form.fromElement(x_elt)
                 if form_ns and form.formNamespace != form_ns:
                     log.debug(