diff --git a/src/common/connection.py b/src/common/connection.py index da034abc1..6a2f11456 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -294,7 +294,8 @@ class CommonConnection: else: def encrypt_thread(msg, keyID, always_trust=False): # encrypt message. This function returns (msgenc, error) - return self.gpg.encrypt(msg, [keyID], always_trust) + return self.gpg.encrypt(msg.encode('utf-8'), [keyID], + always_trust) def _on_encrypted(output): msgenc, error = output if error == 'NOT_TRUSTED': diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 5a78c3331..c0e1c9ddf 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -34,6 +34,7 @@ import sys import operator import hashlib import gobject +import locale from time import (altzone, daylight, gmtime, localtime, mktime, strftime, time as time_time, timezone, tzname) @@ -1157,7 +1158,8 @@ class ConnectionHandlersBase: decmsg = self.gpg.decrypt(encmsg, keyID) decmsg = self.connection.Dispatcher.replace_non_character(decmsg) # \x00 chars are not allowed in C (so in GTK) - obj.msgtxt = helpers.decode_string(decmsg.replace('\x00', '')) + obj.msgtxt = decmsg.replace('\x00', '').encode( + locale.getpreferredencoding()).decode('utf-8') obj.encrypted = 'xep27' self.gpg_messages_to_decrypt.remove([encmsg, keyID, obj]) diff --git a/src/common/gpg.py b/src/common/gpg.py index 0cca079a4..2f7957626 100644 --- a/src/common/gpg.py +++ b/src/common/gpg.py @@ -31,7 +31,6 @@ if HAVE_GPG: class GnuPG(gnupg.GPG): def __init__(self, use_agent=False): gnupg.GPG.__init__(self) - gnupg.GPG.decode_errors = 'replace' self.passphrase = None self.use_agent = use_agent self.always_trust = False