Skip to content

Commit

Permalink
fix downloads: TextDecoder is not the same as String.fromCharCode.
Browse files Browse the repository at this point in the history
despite what you might read elsewhere.
It would be easier if the crypto functions just handled Uint8Arrays directly...
  • Loading branch information
totaam committed Feb 26, 2024
1 parent edf32fa commit 0ce0a70
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
13 changes: 7 additions & 6 deletions html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1556,10 +1556,12 @@ class XpraClient {
system_tray: true,
//we cannot handle this (GTK only):
named_cursors: false,
// printing
"file-transfer": this.file_transfer,
printing: this.printing,
"file-size-limit": 4 * 1024,
// file-transfer and printing:
"file": {
"enabled": true,
"printing": this.printing,
"size-limit": 32 * 1024 * 1024,
},
});
}

Expand Down Expand Up @@ -4840,9 +4842,8 @@ class XpraClient {
if (data.length == filesize) {
//got the whole file
if (digest) {
digest.update(Utilities.Uint8ToString(data));
digest.update(Utilities.ArrayBufferToString(data));
this.log("digest.update(", data, ")");
this.log("digest update string:", Utilities.Uint8ToString(data));
if (!this.verify_digest(digest, options[digest.algorithm])) {
return;
}
Expand Down
8 changes: 6 additions & 2 deletions html5/js/Utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ const Utilities = {
return StringToUint8(v.toString());
},

ArrayBufferToBase64(uintArray) {
ArrayBufferToString(uintArray) {
// apply in chunks of 10400 to avoid call stack overflow
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply
let s = "";
Expand Down Expand Up @@ -485,7 +485,11 @@ const Utilities = {
);
}
}
return window.btoa(s);
return s;
},

ArrayBufferToBase64(uintArray) {
return window.btoa(Utilities.ArrayBufferToString(uintArray));
},

ToBase64(v) {
Expand Down

0 comments on commit 0ce0a70

Please sign in to comment.