aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/src
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-05-09 17:40:57 +0000
committerMaximilian Krambach <[email protected]>2018-05-09 17:40:57 +0000
commitc92326cc257cf7c8b6c0ddc43ec81573c409bc64 (patch)
treeec6faf1f4e72496e9cc53135a2420131d3771874 /lang/js/src
parentMerge branch 'master' into javascript-binding (diff)
downloadgpgme-c92326cc257cf7c8b6c0ddc43ec81573c409bc64.tar.gz
gpgme-c92326cc257cf7c8b6c0ddc43ec81573c409bc64.zip
js: more testing of nativeMessaging connection
-- * There were some inconsistencies between utf-8, transfer and browsers' utf16, which broke characters that were split between individual messages. src/Connection now contains a workaround that reassembles javascripts' format from passed base64 strings. This needs someone more experienced looking. * Added several new tests which were failing during initial debugging of this issue * reorganized BrowsertestExtension to avoid cluttering.
Diffstat (limited to '')
-rw-r--r--lang/js/src/Connection.js19
1 files changed, 18 insertions, 1 deletions
diff --git a/lang/js/src/Connection.js b/lang/js/src/Connection.js
index 2c8792d6..64621f60 100644
--- a/lang/js/src/Connection.js
+++ b/lang/js/src/Connection.js
@@ -181,7 +181,8 @@ class Answer{
if (!this._response.hasOwnProperty(key)){
this._response[key] = '';
}
- this._response[key] = this._response[key].concat(msg[key]);
+ // console.log(msg[key]);
+ this._response[key] += msg[key];
}
//params should not change through the message
else if (poa.params.indexOf(key) >= 0){
@@ -214,6 +215,22 @@ class Answer{
* TODO: does not care yet if completed.
*/
get message(){
+ let keys = Object.keys(this._response);
+ let poa = permittedOperations[this.operation].answer;
+ for (let i=0; i < keys.length; i++) {
+ if (poa.data.indexOf(keys[i]) >= 0){
+ if (this._response.base64 == true){
+ let respatob = atob(this._response[keys[i]]);
+
+ let result = decodeURIComponent(
+ respatob.split('').map(function(c) {
+ return '%' +
+ ('00' + c.charCodeAt(0).toString(16)).slice(-2);
+ }).join(''));
+ this._response[keys[i]] = result;
+ }
+ }
+ }
return this._response;
}
}