From 06503f83aadd4fac72197f35fef1ef0853fce393 Mon Sep 17 00:00:00 2001 From: Goffi Date: Thu, 12 Nov 2020 14:53:15 +0100 Subject: [PATCH] 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. --- sat/plugins/plugin_xep_0363.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sat/plugins/plugin_xep_0363.py b/sat/plugins/plugin_xep_0363.py index c6d62ee4..f4261260 100644 --- a/sat/plugins/plugin_xep_0363.py +++ b/sat/plugins/plugin_xep_0363.py @@ -24,7 +24,6 @@ from urllib import parse 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 @@ class XEP_0363: 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}")