summaryrefslogtreecommitdiff
path: root/plugins/gpg
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2012-11-05 14:54:33 +0000
committerFlorent Le Coz <louiz@louiz.org>2012-11-05 15:03:20 +0000
commitbe64b18b2f069b557db3721ae954917473214168 (patch)
tree109fcfcf2ca88ebb5b3d29139b534c4d25fdd0c9 /plugins/gpg
parentcae686760c6b96440ace30605824ecf7c4349157 (diff)
downloadpoezio-be64b18b2f069b557db3721ae954917473214168.tar.gz
poezio-be64b18b2f069b557db3721ae954917473214168.tar.bz2
poezio-be64b18b2f069b557db3721ae954917473214168.tar.xz
poezio-be64b18b2f069b557db3721ae954917473214168.zip
Display an error and don’t send the message if gpg failed to encrypt a message.
Diffstat (limited to 'plugins/gpg')
-rw-r--r--plugins/gpg/__init__.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/plugins/gpg/__init__.py b/plugins/gpg/__init__.py
index 00d896cd..a60cbbdb 100644
--- a/plugins/gpg/__init__.py
+++ b/plugins/gpg/__init__.py
@@ -131,9 +131,15 @@ class Plugin(BasePlugin):
# cannot be encrypted.
del message['xhtml_im']
encrypted_element = ET.Element('{%s}x' % (NS_ENCRYPTED,))
- encrypted_element.text = self.remove_gpg_headers(xml.sax.saxutils.escape(str(self.gpg.encrypt(message['body'], self.config.get(to.bare, '', section='keys'), always_trust=True))))
+ text = self.gpg.encrypt(message['body'], self.config.get(to.bare, '', section='keys'), always_trust=True)
+ if not text:
+ self.core.information('Could not encrypt message to %s' % (to.full),)
+ # If we could not encrypt the message, don't send anything
+ message['body'] = ''
+ return
+ encrypted_element.text = self.remove_gpg_headers(xml.sax.saxutils.escape(str(text)))
message.append(encrypted_element)
- message['body'] = 'This message has been encrypted.'
+ message['body'] = 'This message has been encrypted using the GPG key with id: %s' % self.keyid
def on_conversation_msg(self, message, tab):
"""