@@ -159,16 +159,17 @@ export class GmailParser {
159159 GmailParser . findAttachments ( msgOrPayloadOrPart . payload , internalMsgId , internalResults ) ;
160160 }
161161 if ( 'parts' in msgOrPayloadOrPart ) {
162- const contentType = msgOrPayloadOrPart . headers ?. find ( x => x . name . toLowerCase ( ) === 'content-type' ) ;
162+ const contentType = msgOrPayloadOrPart . headers ?. find ( header => header . name . toLowerCase ( ) === 'content-type' ) ;
163163 const parts = msgOrPayloadOrPart . parts ?? [ ] ;
164- // are we dealing with a PGP/MIME encrypted message?
165- const pgpEncrypted = Boolean (
166- parts . length === 2 &&
167- contentType ?. value . startsWith ( 'multipart/encrypted' ) &&
168- ( contentType . value . includes ( 'protocol="application/pgp-encrypted"' ) || parts [ 0 ] . mimeType === 'application/pgp-encrypted' )
169- ) ;
164+ const containsMultipartAlternative = parts . find ( part => part . mimeType === 'multipart/alternative' ) ;
170165 // ignore plain inline attachments
171- if ( msgOrPayloadOrPart . mimeType !== 'multipart/related' || parts . length !== 2 ) {
166+ if ( ! contentType ?. value . startsWith ( 'multipart/related' ) || ! containsMultipartAlternative ) {
167+ // are we dealing with a PGP/MIME encrypted message?
168+ const pgpEncrypted = Boolean (
169+ parts . length === 2 &&
170+ contentType ?. value . startsWith ( 'multipart/encrypted' ) &&
171+ ( contentType . value . includes ( 'protocol="application/pgp-encrypted"' ) || parts [ 0 ] . mimeType === 'application/pgp-encrypted' )
172+ ) ;
172173 for ( const [ i , part ] of parts . entries ( ) ) {
173174 GmailParser . findAttachments ( part , internalMsgId , internalResults , {
174175 pgpEncryptedIndex : pgpEncrypted ? i : undefined ,
0 commit comments