@@ -43,7 +43,7 @@ export class ThunderbirdElementReplacer extends WebmailElementReplacer {
4343 } else if ( this . resemblesSignedMsg ( emailBodyToParse ) ) {
4444 await this . messageVerify ( signerKeys ) ;
4545 }
46- if ( emailBodyToParse && attachments . length ) {
46+ if ( attachments . length ) {
4747 const fcAttachments = await BrowserMsg . send . bg . await . thunderbirdGetDownloadableAttachment ( { attachments } ) ;
4848 for ( const fcAttachment of fcAttachments ) {
4949 await this . attachmentUiRenderer ( fcAttachment , signerKeys , emailBodyToParse ) ;
@@ -59,7 +59,7 @@ export class ThunderbirdElementReplacer extends WebmailElementReplacer {
5959 verificationPubs,
6060 } ) ;
6161 if ( result . success && result . content ) {
62- const decryptedMsg = result . content . toUtfStr ( ) ;
62+ const decryptedContent = result . content . toUtfStr ( ) ;
6363 const encryptionStatus = result . isEncrypted ? 'encrypted' : 'not encrypted' ;
6464 let verificationStatus = '' ;
6565 if ( result ?. signature ) {
@@ -71,7 +71,7 @@ export class ThunderbirdElementReplacer extends WebmailElementReplacer {
7171 verificationStatus = 'not signed' ;
7272 }
7373 }
74- const pgpBlock = this . generatePgpBlockTemplate ( encryptionStatus , verificationStatus , decryptedMsg ) ;
74+ const pgpBlock = this . generatePgpBlockTemplate ( encryptionStatus , verificationStatus , decryptedContent ) ;
7575 $ ( 'body' ) . html ( pgpBlock ) ; // xss-sanitized
7676 } else {
7777 const decryptErr = result as DecryptError ;
@@ -110,8 +110,8 @@ export class ThunderbirdElementReplacer extends WebmailElementReplacer {
110110 $ ( 'body' ) . html ( pgpBlock ) ; // xss-sanitized
111111 } ;
112112
113- private attachmentUiRenderer = async ( fcAttachment : ThunderbirdAttachment , verificationPubs : string [ ] , plaintext : string ) => {
114- if ( fcAttachment . treatAs === 'encryptedFile' ) {
113+ private attachmentUiRenderer = async ( fcAttachment : ThunderbirdAttachment , verificationPubs : string [ ] , emailBodyToParse : string ) => {
114+ if ( fcAttachment . treatAs === 'encryptedFile' && emailBodyToParse ) {
115115 const generatedPgpTemplate = this . generatePgpAttachmentTemplate ( fcAttachment . name , fcAttachment . data ) ;
116116 $ ( '.pgp_attachments_block' ) . append ( generatedPgpTemplate ) ; // xss-sanitized
117117 } else if (
@@ -122,7 +122,7 @@ export class ThunderbirdElementReplacer extends WebmailElementReplacer {
122122 } else if ( fcAttachment . treatAs === 'signature' ) {
123123 const sigText = new TextDecoder ( 'utf-8' ) . decode ( fcAttachment . data ) . trim ( ) ;
124124 if ( this . resemblesSignedMsg ( sigText ) ) {
125- await this . messageVerify ( verificationPubs , { plaintext, sigText } ) ;
125+ await this . messageVerify ( verificationPubs , { plaintext : emailBodyToParse , sigText } ) ;
126126 }
127127 }
128128 } ;
@@ -175,6 +175,7 @@ export class ThunderbirdElementReplacer extends WebmailElementReplacer {
175175 if ( result . success && result . content ) {
176176 await BrowserMsg . send . bg . await . thunderbirdInitiateAttachmentDownload ( { decryptedFileName, decryptedContent : result . content } ) ;
177177 }
178+ // no need to handle DecryptErrTypes.needPassphrase it was already handled by this.messageDecrypt()
178179 }
179180 } ;
180181
0 commit comments