changeset b69da671b23f in /home/hg/repos/gajim

branches: 
details:http://hg.gajim.org/gajim?cmd=changeset;node=b69da671b23f
description: fix using GPG with non-utf8 OS. Fixes #7227

diffstat:

 src/common/connection.py          |  3 ++-
 src/common/connection_handlers.py |  4 +++-
 src/common/gpg.py                 |  1 -
 3 files changed, 5 insertions(+), 3 deletions(-)

diffs (45 lines):

diff -r b6046ea500e6 -r b69da671b23f src/common/connection.py
--- a/src/common/connection.py  Thu Jun 20 20:47:42 2013 +0200
+++ b/src/common/connection.py  Thu Jun 20 20:48:34 2013 +0200
@@ -294,7 +294,8 @@
             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 -r b6046ea500e6 -r b69da671b23f src/common/connection_handlers.py
--- a/src/common/connection_handlers.py Thu Jun 20 20:47:42 2013 +0200
+++ b/src/common/connection_handlers.py Thu Jun 20 20:48:34 2013 +0200
@@ -34,6 +34,7 @@
 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 @@
         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 -r b6046ea500e6 -r b69da671b23f src/common/gpg.py
--- a/src/common/gpg.py Thu Jun 20 20:47:42 2013 +0200
+++ b/src/common/gpg.py Thu Jun 20 20:48:34 2013 +0200
@@ -31,7 +31,6 @@
     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
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to