diff options
author | Maxime “pep” Buquet <pep@bouah.net> | 2021-07-17 12:37:41 +0200 |
---|---|---|
committer | Maxime “pep” Buquet <pep@bouah.net> | 2022-03-16 08:09:11 +0100 |
commit | ccf9c3e4e1e6cfdfcd37d340df60f99c95a8a753 (patch) | |
tree | 77cb6a844de357b5058230758ae9d5305d048846 | |
parent | 2fd3a9ef4865097d9d86ecb7d0101ecc4d1bde8d (diff) | |
download | poezio-ccf9c3e4e1e6cfdfcd37d340df60f99c95a8a753.tar.gz poezio-ccf9c3e4e1e6cfdfcd37d340df60f99c95a8a753.tar.bz2 poezio-ccf9c3e4e1e6cfdfcd37d340df60f99c95a8a753.tar.xz poezio-ccf9c3e4e1e6cfdfcd37d340df60f99c95a8a753.zip |
plugin_e2ee: check all encrypted tags in _decrypt and _encrypt
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r-- | poezio/plugin_e2ee.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/poezio/plugin_e2ee.py b/poezio/plugin_e2ee.py index c5c6d802..673ea728 100644 --- a/poezio/plugin_e2ee.py +++ b/poezio/plugin_e2ee.py @@ -383,18 +383,17 @@ class E2EEPlugin(BasePlugin): async def _decrypt(self, message: Message, tab: ChatTabs, passthrough: bool = True) -> None: - has_eme = False + has_eme: bool = False if message.xml.find('{%s}%s' % (EME_NS, EME_TAG)) is not None and \ message['eme']['namespace'] == self.eme_ns: has_eme = True - has_encrypted_tag = False + has_encrypted_tag: bool = False if not has_eme and self.encrypted_tags is not None: + tmp: bool = True for (namespace, tag) in self.encrypted_tags: - if message.xml.find('{%s}%s' % (namespace, tag)) is not None: - # TODO: count all encrypted tags. - has_encrypted_tag = True - break + tmp = tmp and message.xml.find('{%s}%s' % (namespace, tag)) is not None + has_encrypted_tag = tmp if not has_eme and not has_encrypted_tag: return None @@ -439,14 +438,14 @@ class E2EEPlugin(BasePlugin): # Is this message already encrypted? Do we need to do all these # checks? Such as an OMEMO heartbeat. - has_encrypted_tag = False + has_encrypted_tag: bool = False if self.encrypted_tags is not None: + tmp: bool = True for (namespace, tag) in self.encrypted_tags: - if message.xml.find('{%s}%s' % (namespace, tag)) is not None: - # TODO: count all encrypted tags. - has_encrypted_tag = True - log.debug('Message already contains an encrypted tag') - break + tmp = tmp and message.xml.find('{%s}%s' % (namespace, tag)) is not None + has_encrypted_tag = tmp + if has_encrypted_tag: + log.debug('Message already contains encrypted tags') # Find who to encrypt to. If in a groupchat this can be multiple JIDs. # It is possible that we are not able to find a jid (e.g., semi-anon |