From 78b562f7a53770e2fc895e9e9833d202cd759d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Tue, 28 Mar 2017 18:15:29 +0200 Subject: [PATCH] Make PGP encoding configurable python-gnupg uses latin1 as default encoding because GPG itself uses latin1 as default. We should not override this default with getpreferredencoding, because getpreferredencoding maybe returns something else than what GPG is configured on that system. Example: On Windows GPG is run in default mode with 'latin1' getpreferredencoding returns 'cp1252' The approach would be now to default to latin1 as it is GPGs default. And if the User sets a different ecoding for GPG he has to set it in Gajim aswell. --- src/common/config.py | 1 + src/common/gpg.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/config.py b/src/common/config.py index 30eadc444..c2fb85293 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -315,6 +315,7 @@ class Config: 'positive_184_ack': [ opt_bool, False, _('If enabled, Gajim will show an icon to show that sent message has been received by your contact')], 'show_avatar_in_tabs': [ opt_bool, False, _('Show a mini avatar in chat window tabs and in window icon')], 'use_keyring': [opt_bool, True, _('If True, Gajim will use the Systems Keyring to store account passwords.')], + 'pgp_encoding': [ opt_str, '', _('Sets the encoding used by python-gnupg'), True], }, {}) __options_per_key = { diff --git a/src/common/gpg.py b/src/common/gpg.py index cff37669b..4cc2b966c 100644 --- a/src/common/gpg.py +++ b/src/common/gpg.py @@ -22,9 +22,10 @@ ## along with Gajim. If not, see . ## -from common.gajim import HAVE_GPG, GPG_BINARY import os import logging +from common import gajim +from common.gajim import HAVE_GPG, GPG_BINARY if HAVE_GPG: import gnupg @@ -33,7 +34,9 @@ if HAVE_GPG: class GnuPG(gnupg.GPG): def __init__(self, use_agent=False): gnupg.GPG.__init__(self, gpgbinary=GPG_BINARY) - self.encoding = 'utf-8' + encoding = gajim.config.get('pgp_encoding') + if encoding: + self.encoding = encoding self.decode_errors = 'replace' self.passphrase = None self.use_agent = use_agent