summaryrefslogtreecommitdiff
path: root/poezio/plugin_e2ee.py
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2019-07-01 01:16:40 +0200
committerMaxime “pep” Buquet <pep@bouah.net>2019-07-01 19:42:45 +0200
commit98102d075c7163f2ca11f1758e14c895fe6643d9 (patch)
treeeacbcff65db1102ef2ae7ac8e39f4ca5f22a689d /poezio/plugin_e2ee.py
parent812d9485e39ddb54e069ea9ddfb046280ae43cf8 (diff)
downloadpoezio-98102d075c7163f2ca11f1758e14c895fe6643d9.tar.gz
poezio-98102d075c7163f2ca11f1758e14c895fe6643d9.tar.bz2
poezio-98102d075c7163f2ca11f1758e14c895fe6643d9.tar.xz
poezio-98102d075c7163f2ca11f1758e14c895fe6643d9.zip
e2ee-api: Add <eme/> only if <body/> is present
As per discussion in jdev@ Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Diffstat (limited to 'poezio/plugin_e2ee.py')
-rw-r--r--poezio/plugin_e2ee.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/poezio/plugin_e2ee.py b/poezio/plugin_e2ee.py
index ef58a051..1580bd6d 100644
--- a/poezio/plugin_e2ee.py
+++ b/poezio/plugin_e2ee.py
@@ -169,23 +169,31 @@ class E2EEPlugin(BasePlugin):
log.debug('Sending %s message: %r', self.encryption_name, message['body'])
- message['eme']['namespace'] = self.eme_ns
- message['eme']['name'] = self.encryption_name
+ has_body = message.xml.find('{%s}%s' % (JCLIENT_NS, 'body')) is not None
# Call the enabled encrypt method
self._enabled_tabs[jid](message, tab)
+ if has_body:
+ # Only add EME tag if the message has a body.
+ # Per discussion in jdev@:
+ # The receiving client needs to know the message contains
+ # meaningful information or not to display notifications to the
+ # user, and not display anything when it's e.g., a chatstate.
+ # This does leak the fact that the encrypted payload contains a
+ # message.
+ message['eme']['namespace'] = self.eme_ns
+ message['eme']['name'] = self.encryption_name
+
+ if self.replace_body_with_eme:
+ self.core.xmpp['xep_0380'].replace_body_with_eme(message)
+
# Filter stanza with the whitelist if we don't do stanza encryption
if not self.stanza_encryption:
for elem in message.xml[:]:
if elem.tag not in self.tag_whitelist:
message.xml.remove(elem)
- if self.replace_body_with_eme:
- body = message.xml.find('{%s}%s' % (JCLIENT_NS, 'body'))
- if body is not None:
- self.core.xmpp['xep_0380'].replace_body_with_eme(message)
-
log.debug('Encrypted %s message: %r', self.encryption_name, message['body'])
return None