diff sat/plugins/plugin_xep_0363.py @ 3399:506fa3d91d3a

plugin XEP-0363: fixed invalid reference to `slot` in catched exception: `slot` was referenced in an exception where it can't exist. This fix avoid a crash and skip the handler when a StanzaError is catched.
author Goffi <goffi@goffi.org>
date Thu, 12 Nov 2020 14:53:15 +0100
parents 6505e5cc6ab9
children be6d91572633
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0363.py	Thu Nov 12 14:53:15 2020 +0100
+++ b/sat/plugins/plugin_xep_0363.py	Thu Nov 12 14:53:15 2020 +0100
@@ -24,7 +24,6 @@
 from wokkel import disco, iwokkel
 from zope.interface import implementer
 from twisted.words.protocols.jabber import jid, xmlstream, error
-from twisted.words.xish import domish
 from twisted.internet import reactor
 from twisted.internet import defer
 from twisted.web import client as http_client
@@ -375,13 +374,17 @@
             try:
                 slot = handler.callback(client, request)
             except error.StanzaError as e:
-                log.warning(f"a stanza error has been raised while processing HTTP Upload of request: {e}")
+                log.warning(
+                    "a stanza error has been raised while processing HTTP Upload of "
+                    f"request: {e}"
+                )
                 if err is None:
                     # we keep the first error to return its condition later,
                     # if no other callback handle the request
                     err = e
-            if slot:
-                break
+            else:
+                if slot:
+                    break
         else:
             log.warning(
                 _("no service can handle HTTP Upload request: {elt}")