diff options
author | Ivan Alejandro <ivanalejandro0@gmail.com> | 2013-10-23 10:39:28 -0300 |
---|---|---|
committer | Ivan Alejandro <ivanalejandro0@gmail.com> | 2013-10-23 10:55:32 -0300 |
commit | 9cd2ee1e1b96ad521967096424b0b9ff16ed82da (patch) | |
tree | 1329a28fae471fa96fcebdf69c15641dcd6508e7 /keymanager | |
parent | 2e1e258d6efadcd3a6ba34cd3194fe3e5c71e177 (diff) |
Return unicode in order to solve encoding issues.
Diffstat (limited to 'keymanager')
-rw-r--r-- | keymanager/changes/bug-4000_suport-non-ascii | 1 | ||||
-rw-r--r-- | keymanager/src/leap/keymanager/openpgp.py | 10 |
2 files changed, 9 insertions, 2 deletions
diff --git a/keymanager/changes/bug-4000_suport-non-ascii b/keymanager/changes/bug-4000_suport-non-ascii new file mode 100644 index 00000000..cb1b78f1 --- /dev/null +++ b/keymanager/changes/bug-4000_suport-non-ascii @@ -0,0 +1 @@ + o Return unicode decrypted text to avoid encoding issues. Related to #4000. diff --git a/keymanager/src/leap/keymanager/openpgp.py b/keymanager/src/leap/keymanager/openpgp.py index 64123318..8ec86391 100644 --- a/keymanager/src/leap/keymanager/openpgp.py +++ b/keymanager/src/leap/keymanager/openpgp.py @@ -26,6 +26,7 @@ import os import re import shutil import tempfile +import locale from gnupg import GPG from gnupg.gnupg import GPGUtilities @@ -482,7 +483,7 @@ class OpenPGPScheme(EncryptionScheme): :type verify: OpenPGPKey :return: The decrypted data. - :rtype: str + :rtype: unicode @raise InvalidSignature: Raised if unable to verify the signature with C{verify} key. @@ -504,7 +505,12 @@ class OpenPGPScheme(EncryptionScheme): raise errors.InvalidSignature( 'Failed to verify signature with key %s: %s' % (verify.key_id, stderr)) - return result.data + + # XXX: this is the encoding used by gpg module + # https://github.com/isislovecruft/python-gnupg/\ + # blob/master/gnupg/_meta.py#L121 + encoding = locale.getpreferredencoding() + return result.data.decode(encoding, 'replace') def is_encrypted(self, data): """ |