From 73a4f8d8f6639e819dc4ffa2aa23aaf9139c9ff3 Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 16 Oct 2019 08:39:52 +0200 Subject: [PATCH] plugin OTR: work around a bad exception raised in potr --- sat/plugins/plugin_sec_otr.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sat/plugins/plugin_sec_otr.py b/sat/plugins/plugin_sec_otr.py index 11cb2e35..9adeadb8 100644 --- a/sat/plugins/plugin_sec_otr.py +++ b/sat/plugins/plugin_sec_otr.py @@ -637,7 +637,11 @@ class OTR(object): next(iter(data["message"].values())) ) # FIXME: Q&D fix for message refactoring, message is now a dict res = otrctx.receiveMessage(message.encode("utf-8")) - except potr.context.UnencryptedMessage: + except (potr.context.UnencryptedMessage, potr.context.NotOTRMessage): + # potr has a bug with Python 3 and test message against str while bytes are + # expected, resulting in a NoOTRMessage raised instead of UnencryptedMessage; + # so we catch NotOTRMessage as a workaround + # TODO: report this upstream encrypted = False if otrctx.state == potr.context.STATE_ENCRYPTED: log.warning(