|
3 | 3 | 'use strict';
|
4 | 4 |
|
5 | 5 | import { BrowserMsg } from '../../../common/browser/browser-msg.js';
|
6 |
| -import { Attachment } from '../../../common/core/attachment.js'; |
| 6 | +import { Attachment, ThunderbirdAttachment } from '../../../common/core/attachment.js'; |
7 | 7 | import { Buf } from '../../../common/core/buf.js';
|
8 | 8 | import { KeyUtil } from '../../../common/core/crypto/key.js';
|
9 | 9 | import { DecryptError, DecryptErrTypes, MsgUtil, VerifyRes } from '../../../common/core/crypto/pgp/msg-util.js';
|
@@ -44,11 +44,9 @@ export class ThunderbirdElementReplacer extends WebmailElementReplacer {
|
44 | 44 | await this.messageVerify(signerKeys);
|
45 | 45 | }
|
46 | 46 | if (emailBodyToParse && attachments.length) {
|
47 |
| - for (const attachment of attachments) { |
48 |
| - const fcAttachment = await BrowserMsg.send.bg.await.thunderbirdGetDownloadableAttachment({ attachment }); |
49 |
| - if (fcAttachment) { |
50 |
| - await this.attachmentUiRenderer(attachment.name, fcAttachment, signerKeys, emailBodyToParse); |
51 |
| - } |
| 47 | + const fcAttachments = await BrowserMsg.send.bg.await.thunderbirdGetDownloadableAttachment({ attachments }); |
| 48 | + for (const fcAttachment of fcAttachments) { |
| 49 | + await this.attachmentUiRenderer(fcAttachment, signerKeys, emailBodyToParse); |
52 | 50 | }
|
53 | 51 | }
|
54 | 52 | }
|
@@ -112,14 +110,17 @@ export class ThunderbirdElementReplacer extends WebmailElementReplacer {
|
112 | 110 | $('body').html(pgpBlock); // xss-sanitized
|
113 | 111 | };
|
114 | 112 |
|
115 |
| - private attachmentUiRenderer = async (attachmentName: string, fcAttachment: Buf, verificationPubs: string[], plaintext: string) => { |
116 |
| - if (attachmentName.endsWith('.pgp')) { |
117 |
| - const generatedPgpTemplate = this.generatePgpAttachmentTemplate(attachmentName, fcAttachment); |
| 113 | + private attachmentUiRenderer = async (fcAttachment: ThunderbirdAttachment, verificationPubs: string[], plaintext: string) => { |
| 114 | + if (fcAttachment.treatAs === 'encryptedFile') { |
| 115 | + const generatedPgpTemplate = this.generatePgpAttachmentTemplate(fcAttachment.name, fcAttachment.data); |
118 | 116 | $('.pgp_attachments_block').append(generatedPgpTemplate); // xss-sanitized
|
119 |
| - } else if (Attachment.encryptedMsgNames.some(a => attachmentName.includes(a)) && !this.emailBodyFromThunderbirdMail) { |
120 |
| - await this.messageDecrypt(verificationPubs, fcAttachment); |
121 |
| - } else if (attachmentName.endsWith('.asc')) { |
122 |
| - const sigText = new TextDecoder('utf-8').decode(fcAttachment).trim(); |
| 117 | + } else if ( |
| 118 | + (fcAttachment.treatAs === 'encryptedMsg' || Attachment.encryptedMsgNames.some(a => fcAttachment.name.includes(a))) && |
| 119 | + !this.emailBodyFromThunderbirdMail |
| 120 | + ) { |
| 121 | + await this.messageDecrypt(verificationPubs, fcAttachment.data); |
| 122 | + } else if (fcAttachment.treatAs === 'signature') { |
| 123 | + const sigText = new TextDecoder('utf-8').decode(fcAttachment.data).trim(); |
123 | 124 | if (this.resemblesSignedMsg(sigText)) {
|
124 | 125 | await this.messageVerify(verificationPubs, { plaintext, sigText });
|
125 | 126 | }
|
|
0 commit comments