Browse Source

P4TB-409: Convert raw UTF-8 bytes to JS string before encrypting (TB 91 compat issue).

master
Jörg Knobloch 10 months ago
parent
commit
071279929d
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      addon/content/pEpMimeEncrypt.js

+ 12
- 1
addon/content/pEpMimeEncrypt.js View File

@ -82,7 +82,18 @@ MimeEncrypt.prototype = {
},
mimeCryptoWriteBlock(buffer, length) {
this.inBuffer += buffer.substr(0, length);
// Apparently this interface always delivered raw bytes, but until TB 91 we never noticed
// since all non-ASCII content arrived as base64 or QP. To be cautious, we'll only convert
// from UTF-8 starting at version 91.
if (this.controller.MOZ_APP_VERSION >= 91) {
let arr = new Uint8Array(length);
for (let i = 0; i < length; i++) {
arr[i] = buffer.charCodeAt(i);
}
this.inBuffer += new TextDecoder().decode(arr);
} else {
this.inBuffer += buffer.substr(0, length);
}
return null;
},


Loading…
Cancel
Save