js: Fix wrong encoding in received error messages
authorMaximilian Krambach <maximilian.krambach@intevation.de>
Tue, 24 Jul 2018 12:50:54 +0000 (14:50 +0200)
committerMaximilian Krambach <maximilian.krambach@intevation.de>
Tue, 24 Jul 2018 12:50:54 +0000 (14:50 +0200)
--

* The libgpg error strings arrive in the browser in a different
  encoding than used by browsers. Escaping and then decoding it
  should cover most languages in the supported browsers.

lang/js/src/Connection.js

index ef54dd6..d89fa72 100644 (file)
@@ -240,7 +240,8 @@ class Answer{
             switch (key) {
             case 'type':
                 if (_decodedResponse.type === 'error'){
-                    return (gpgme_error('GNUPG_ERROR', _decodedResponse.msg));
+                    return (gpgme_error('GNUPG_ERROR',
+                        decodeURIComponent(escape(_decodedResponse.msg))));
                 } else if (poa.type.indexOf(_decodedResponse.type) < 0){
                     return gpgme_error('CONN_UNEXPECTED_ANSWER');
                 }