@@ -31,10 +31,10 @@ export class ThunderbirdElementReplacer extends WebmailElementReplacer {
31
31
public handleThunderbirdMessageParsing = async ( ) => {
32
32
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
33
33
this . acctEmail = ( await BrowserMsg . send . bg . await . thunderbirdGetCurrentUser ( ) ) ! ;
34
- const emailBodyToParse = $ ( 'div.moz-text-plain' ) . text ( ) . trim ( ) || $ ( 'div.moz-text-html' ) . text ( ) . trim ( ) ;
35
- const { processableAttachments : fcAttachments , from : from } = await BrowserMsg . send . bg . await . thunderbirdGetDownloadableAttachment ( ) ;
34
+ const emailBodyToParse = $ ( 'div.moz-text-plain' ) . text ( ) . trim ( ) || $ ( 'div.moz-text-html' ) . text ( ) . trim ( ) || $ ( 'div.moz-text-flowed' ) . text ( ) . trim ( ) ;
35
+ const { processableAttachments : fcAttachments , from : signerEmail } = await BrowserMsg . send . bg . await . thunderbirdGetDownloadableAttachment ( ) ;
36
36
if ( Catch . isThunderbirdMail ( ) ) {
37
- const parsedPubs = ( await ContactStore . getOneWithAllPubkeys ( undefined , from ) ) ?. sortedPubkeys ?? [ ] ;
37
+ const parsedPubs = ( await ContactStore . getOneWithAllPubkeys ( undefined , signerEmail ) ) ?. sortedPubkeys ?? [ ] ;
38
38
const verificationPubs = parsedPubs . map ( key => KeyUtil . armor ( key . pubkey ) ) ;
39
39
if ( this . resemblesAsciiArmoredMsg ( emailBodyToParse ) ) {
40
40
await this . messageDecrypt ( verificationPubs , this . emailBodyFromThunderbirdMail ) ;
@@ -101,13 +101,13 @@ export class ThunderbirdElementReplacer extends WebmailElementReplacer {
101
101
let pgpBlockContent = '' ;
102
102
if ( result . content ) {
103
103
verificationStatus = result . match ? 'signed' : 'not signed' ;
104
- if ( result . signerLongids ) {
104
+ if ( ! result . signerLongids . length ) {
105
105
verificationStatus = `could not verify signature: missing pubkey ${ result . signerLongids } ` ;
106
106
}
107
107
pgpBlockContent = result . content . toUtfStr ( ) ;
108
108
} else if ( result . error ) {
109
109
verificationStatus = `could not verify signature: ${ result . error } ` ;
110
- pgpBlockContent = detachedSignatureParams ?. plaintext || '' ;
110
+ pgpBlockContent = detachedSignatureParams ?. plaintext || this . emailBodyFromThunderbirdMail ;
111
111
}
112
112
const pgpBlock = this . generatePgpBlockTemplate ( 'not encrypted' , verificationStatus , pgpBlockContent ) ;
113
113
$ ( 'body' ) . html ( pgpBlock ) ; // xss-sanitized
@@ -122,10 +122,11 @@ export class ThunderbirdElementReplacer extends WebmailElementReplacer {
122
122
! this . emailBodyFromThunderbirdMail
123
123
) {
124
124
await this . messageDecrypt ( verificationPubs , fcAttachment . data ) ;
125
+ // detached signature verification
125
126
} else if ( fcAttachment . treatAs === 'signature' ) {
126
127
const sigText = new TextDecoder ( 'utf-8' ) . decode ( fcAttachment . data ) . trim ( ) ;
127
128
if ( this . resemblesSignedMsg ( sigText ) ) {
128
- await this . messageVerify ( verificationPubs , { plaintext : emailBodyToParse , sigText } ) ;
129
+ await this . messageVerify ( verificationPubs , { plaintext : emailBodyToParse , sigText : sigText . replace ( '\n=3D' , '\n=' ) } ) ;
129
130
}
130
131
}
131
132
} ;
0 commit comments