Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Commit

Permalink
Correctly ignore multipart/signed (we force multipart/encrypted).
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed Jul 13, 2017
1 parent 4037fbf commit 014dedf
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/mrmimeparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ static int mrmimeparser_get_mime_type(struct mailmime* mime, int* msg_type)
#define MR_MIMETYPE_MP_MIXED 30
#define MR_MIMETYPE_MP_NOT_DECRYPTABLE 40
#define MR_MIMETYPE_MP_REPORT 45
#define MR_MIMETYPE_MP_SIGNED 46
#define MR_MIMETYPE_MP_OTHER 50
#define MR_MIMETYPE_TEXT_PLAIN 60
#define MR_MIMETYPE_TEXT_HTML 70
Expand Down Expand Up @@ -734,6 +735,9 @@ static int mrmimeparser_get_mime_type(struct mailmime* mime, int* msg_type)
else if( strcmp(c->ct_subtype, "encrypted")==0 ) {
return MR_MIMETYPE_MP_NOT_DECRYPTABLE; /* decryptable parts are already converted to other mime parts in mre2ee_decrypt() */
}
else if( strcmp(c->ct_subtype, "signed")==0 ) {
return MR_MIMETYPE_MP_SIGNED;
}
else if( strcmp(c->ct_subtype, "mixed")==0 ) {
return MR_MIMETYPE_MP_MIXED;
}
Expand Down Expand Up @@ -1048,6 +1052,10 @@ static int mrmimeparser_parse_mime_recursive(mrmimeparser_t* ths, struct mailmim
int any_part_added = 0;
clistiter* cur;

if( ths == NULL || mime == NULL ) {
return 0;
}

switch( mime->mm_type )
{
case MAILMIME_SINGLE:
Expand Down Expand Up @@ -1108,6 +1116,18 @@ static int mrmimeparser_parse_mime_recursive(mrmimeparser_t* ths, struct mailmim
}
break;

case MR_MIMETYPE_MP_SIGNED:
/* RFC 1847: "The multipart/signed content type contains exactly two body parts.
The first body part is the body part over which the digital signature was created [...]
The second body part contains the control information necessary to verify the digital signature."
We simpliy take the first body part and skip the rest.
(see https://k9mail.github.io/2016/11/24/OpenPGP-Considerations-Part-I.html for background information why we use encrypted+signed) */
if( (cur=clist_begin(mime->mm_data.mm_multipart.mm_mp_list)) != NULL )
{
any_part_added = mrmimeparser_parse_mime_recursive(ths, (struct mailmime*)clist_content(cur));
}
break;

case MR_MIMETYPE_MP_REPORT:
if( clist_count(mime->mm_data.mm_multipart.mm_mp_list) >= 2 ) /* RFC 6522: the first part is for humans, the second for machines */
{
Expand Down

0 comments on commit 014dedf

Please sign in to comment.