aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/src
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-05-08 16:33:41 +0000
committerMaximilian Krambach <[email protected]>2018-05-08 16:33:41 +0000
commitcca40627b0afa2efc85ef7f5f1a1060a221ff2a2 (patch)
treea77afbd90849bf2da0675e14c0cd41668b32ba56 /lang/js/src
parentjs: fixing errors found by testing: encrypt/decrypt (diff)
downloadgpgme-cca40627b0afa2efc85ef7f5f1a1060a221ff2a2.tar.gz
gpgme-cca40627b0afa2efc85ef7f5f1a1060a221ff2a2.zip
js: more testing
-- * Tests: Under certain circumstances, some data change during encrypt-decrypt. Committing the current state so the problem can be discussed. * Fixes: - disconnecting the test ports after tests are complete - fixed passing of the error message from gpgme-json
Diffstat (limited to '')
-rw-r--r--lang/js/src/Errors.js2
-rw-r--r--lang/js/src/gpgmejs.js11
2 files changed, 7 insertions, 6 deletions
diff --git a/lang/js/src/Errors.js b/lang/js/src/Errors.js
index d26aab18..b71004a5 100644
--- a/lang/js/src/Errors.js
+++ b/lang/js/src/Errors.js
@@ -110,7 +110,7 @@ export function gpgme_error(code = 'GENERIC_ERROR', info){
}
return null;
} else if (code === 'GNUPG_ERROR'){
- return new GPGME_Error(code, info.msg);
+ return new GPGME_Error(code, info);
}
else {
return new GPGME_Error('GENERIC_ERROR');
diff --git a/lang/js/src/gpgmejs.js b/lang/js/src/gpgmejs.js
index 9475b2b0..c1a01377 100644
--- a/lang/js/src/gpgmejs.js
+++ b/lang/js/src/gpgmejs.js
@@ -170,18 +170,19 @@ function putData(message, data){
if (!data){
return gpgme_error('PARAM_WRONG');
} else if (data instanceof Uint8Array){
- let decoder = new TextDecoder('utf8');
message.setParameter('base64', true);
- message.setParameter ('data', decoder.decode(data));
+ message.setParameter ('data', btoa(data));
} else if (typeof(data) === 'string') {
message.setParameter('base64', false);
message.setParameter('data', data);
- } else if ( typeof(data) === 'object' && data.hasOwnProperty(getText)){
+ } else if ( typeof(data) === 'object' && data.hasOwnProperty('getText')){
let txt = data.getText();
if (txt instanceof Uint8Array){
- let decoder = new TextDecoder('utf8');
message.setParameter('base64', true);
- message.setParameter ('data', decoder.decode(txt));
+ message.setParameter ('data', btoa(txt));
+ }
+ else {
+ return gpgme_error('PARAM_WRONG');
}
} else {
return gpgme_error('PARAM_WRONG');