ENGINE-118: Attempt to handle multipart mixed. #comment libetpan apparently doesn't handle multipart/mixed correctly (no part list afterward) ENGINE-118
authorKrista Grothoff <krista@pep-project.org>
Mon, 24 Oct 2016 09:51:01 +0200
branchENGINE-118
changeset 13245c604329c0bf
parent 1323 4501141bf217
child 1348 8e86ccd0804c
ENGINE-118: Attempt to handle multipart mixed. #comment libetpan apparently doesn't handle multipart/mixed correctly (no part list afterward)
src/mime.c
     1.1 --- a/src/mime.c	Wed Oct 19 13:09:48 2016 +0200
     1.2 +++ b/src/mime.c	Mon Oct 24 09:51:01 2016 +0200
     1.3 @@ -1215,6 +1215,23 @@
     1.4      return PEP_STATUS_OK;
     1.5  }
     1.6  
     1.7 +/* memoryhole */
     1.8 +static PEP_STATUS replace_select_headers(
     1.9 +        struct mailmime *part,
    1.10 +        message *msg
    1.11 +    )
    1.12 +{
    1.13 +    PEP_STATUS status = PEP_STATUS_OK;
    1.14 +    
    1.15 +    assert(part);
    1.16 +    assert(msg);
    1.17 +
    1.18 +    if (!part || !msg) 
    1.19 +        return PEP_UNKNOWN_ERROR;
    1.20 +    
    1.21 +    return status;
    1.22 +}
    1.23 +
    1.24  static PEP_STATUS interpret_MIME(
    1.25          struct mailmime *mime,
    1.26          message *msg
    1.27 @@ -1262,6 +1279,39 @@
    1.28                  }
    1.29              }
    1.30          }
    1.31 +        else if (_is_multipart(content, "mixed")) {
    1.32 +            clist *partlist = mime->mm_data.mm_multipart.mm_mp_list;
    1.33 +            if (partlist == NULL)
    1.34 +                return PEP_ILLEGAL_VALUE;
    1.35 +            
    1.36 +            clistiter *cur;
    1.37 +            for (cur = clist_begin(partlist); cur; cur = clist_next(cur)) {
    1.38 +                struct mailmime *part = clist_content(cur);
    1.39 +                if (part == NULL)
    1.40 +                    return PEP_ILLEGAL_VALUE;
    1.41 +                
    1.42 +                content = part->mm_content_type;
    1.43 +                assert(content);
    1.44 +                if (content == NULL)
    1.45 +                    return PEP_ILLEGAL_VALUE;
    1.46 +//                 Content-Type: text/rfc822-headers
    1.47 +//                 Content-Disposition: attachment
    1.48 +//                 
    1.49 +//                 Date: Thu, 16 Jul 2015 11:44:44 +0200
    1.50 +//                 Subject: alternative text/html message with embedded header, unsigned
    1.51 +//                 From: Winston 
    1.52 +//                 To: Julia 
    1.53 +//                 Message-ID: B@memoryhole.example
    1.54 +                if (_is_text_part(content, "rfc822-headers")) {
    1.55 +                    replace_select_headers(part, msg);
    1.56 +                }
    1.57 +                else {
    1.58 +                    status = interpret_MIME(part, msg);
    1.59 +                    if (status)
    1.60 +                        return status;
    1.61 +                }
    1.62 +            }
    1.63 +        }
    1.64          else if (_is_multipart(content, "encrypted")) {
    1.65              if (msg->longmsg == NULL)
    1.66                  msg->longmsg = strdup("");