mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-11-03 19:08:50 +03:00
Resolve #2071 (openpgp.decrypt decrypted text was decoded twice)
This commit is contained in:
parent
eeec1b8b49
commit
01e58c876f
1 changed files with 17 additions and 2 deletions
|
|
@ -268,13 +268,28 @@ export const OpenPGPUserStore = new class {
|
|||
const decryptedKey = await decryptKey(privateKey, 'DECRYPT');
|
||||
if (decryptedKey) {
|
||||
const publicKey = findOpenPGPKey(this.publicKeys, sender/*, sign*/);
|
||||
return await openpgp.decrypt({
|
||||
// 'binary', not the default 'utf8'. What comes out is a MIME
|
||||
// entity whose parts declare their own charset, and the MIME
|
||||
// parser decodes each one. Letting openpgp decode to a string
|
||||
// first meant every non ASCII character was decoded twice and
|
||||
// arrived as U+FFFD: "Verschlüsselter" became "Verschl?sselter".
|
||||
const result = await openpgp.decrypt({
|
||||
message,
|
||||
verificationKeys: publicKey?.key,
|
||||
// expectSigned: true,
|
||||
// signature: '', // Detached signature
|
||||
decryptionKeys: decryptedKey
|
||||
decryptionKeys: decryptedKey,
|
||||
format: 'binary'
|
||||
});
|
||||
// One character per byte, which is what Mime/Encoding decodeText
|
||||
// reads with charCodeAt. Chunked so a large message does not blow
|
||||
// the argument limit of String.fromCharCode.
|
||||
let text = '';
|
||||
for (let j = 0; j < result.data.length; j += 0x8000) {
|
||||
text += String.fromCharCode.apply(null, result.data.subarray(j, j + 0x8000));
|
||||
}
|
||||
result.data = text;
|
||||
return result;
|
||||
}
|
||||
} catch (err) {
|
||||
alert(err);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue