ENGINE-526: make sure we pull the text/html of multipart/related into longmsg_formatted and put the inline attachments into the attachment list
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Mon, 18 Mar 2019 15:37:56 +0100
changeset 33423e11f68497d4
parent 3293 a12a4f13d796
child 3343 df02ace61c84
child 3346 278702033186
ENGINE-526: make sure we pull the text/html of multipart/related into longmsg_formatted and put the inline attachments into the attachment list
src/mime.c
test/src/SuiteMaker.cc
     1.1 --- a/src/mime.c	Mon Feb 11 09:41:00 2019 +0100
     1.2 +++ b/src/mime.c	Mon Mar 18 15:37:56 2019 +0100
     1.3 @@ -13,6 +13,10 @@
     1.4  #include "etpan_mime.h"
     1.5  #include "wrappers.h"
     1.6  
     1.7 +static PEP_STATUS interpret_MIME(struct mailmime *mime,
     1.8 +                                 message *msg);
     1.9 +
    1.10 +
    1.11  static bool is_whitespace(char c)
    1.12  {
    1.13      switch (c) {
    1.14 @@ -1472,6 +1476,63 @@
    1.15      return PEP_STATUS_OK;
    1.16  }
    1.17  
    1.18 +// ONLY for main part!!!
    1.19 +static PEP_STATUS process_multipart_related(struct mailmime *mime,
    1.20 +                                            message *msg) {
    1.21 +    PEP_STATUS status = PEP_STATUS_OK;
    1.22 +
    1.23 +    assert(mime);
    1.24 +    assert(msg);
    1.25 +
    1.26 +    clist *partlist = mime->mm_data.mm_multipart.mm_mp_list;                                                
    1.27 +
    1.28 +    if (partlist == NULL)
    1.29 +        return PEP_ILLEGAL_VALUE;
    1.30 +
    1.31 +    clistiter *cur = clist_begin(partlist);
    1.32 +    struct mailmime *part = clist_content(cur);
    1.33 +    
    1.34 +    if (part == NULL)
    1.35 +        return PEP_ILLEGAL_VALUE;
    1.36 +
    1.37 +    struct mailmime_content *content = part->mm_content_type;    
    1.38 +    assert(content);
    1.39 +    
    1.40 +    if (content == NULL)
    1.41 +        return PEP_ILLEGAL_VALUE;
    1.42 +
    1.43 +    if (_is_text_part(content, "html")) {
    1.44 +        status = interpret_body(part, &msg->longmsg_formatted,
    1.45 +                NULL);
    1.46 +        if (status)
    1.47 +            return status;
    1.48 +    }
    1.49 +    else {
    1.50 +        // ???
    1.51 +        // This is what we would have done before, so... no
    1.52 +        // worse than the status quo. But FIXME!
    1.53 +        status = interpret_MIME(part, msg);
    1.54 +        if (status)
    1.55 +            return status;
    1.56 +    }
    1.57 +    
    1.58 +    for (cur = clist_next(cur); cur; cur = clist_next(cur)) {
    1.59 +        part = clist_content(cur);
    1.60 +        if (part == NULL)
    1.61 +            return PEP_ILLEGAL_VALUE;
    1.62 +
    1.63 +        content = part->mm_content_type;
    1.64 +        assert(content);
    1.65 +        if (content == NULL)
    1.66 +            return PEP_ILLEGAL_VALUE;
    1.67 +
    1.68 +        status = interpret_MIME(part, msg);
    1.69 +        if (status)
    1.70 +            return status;
    1.71 +    }
    1.72 +    return status;
    1.73 +}
    1.74 +
    1.75  static PEP_STATUS interpret_MIME(
    1.76          struct mailmime *mime,
    1.77          message *msg
    1.78 @@ -1517,6 +1578,12 @@
    1.79                      if (status)
    1.80                          return status;
    1.81                  }
    1.82 +                else if (_is_multipart(content, "related") && 
    1.83 +                    msg->longmsg_formatted == NULL) {
    1.84 +                    status = process_multipart_related(part, msg);
    1.85 +                    if (status)
    1.86 +                        return status;
    1.87 +                }
    1.88                  else /* add as attachment */ {
    1.89                      status = interpret_MIME(part, msg);
    1.90                      if (status)
     2.1 --- a/test/src/SuiteMaker.cc	Mon Feb 11 09:41:00 2019 +0100
     2.2 +++ b/test/src/SuiteMaker.cc	Mon Mar 18 15:37:56 2019 +0100
     2.3 @@ -35,7 +35,6 @@
     2.4  #include "Engine358Tests.h"
     2.5  #include "BlacklistAcceptNewKeyTests.h"
     2.6  #include "DecryptAttachPrivateKeyUntrustedTests.h"
     2.7 -#include "ReturnMistrustFprTests.h"
     2.8  #include "BlacklistTests.h"
     2.9  #include "RevokeRegenAttachTests.h"
    2.10  #include "PepSubjectReceivedTests.h"
    2.11 @@ -85,7 +84,6 @@
    2.12      "Engine358Tests",
    2.13      "BlacklistAcceptNewKeyTests",
    2.14      "DecryptAttachPrivateKeyUntrustedTests",
    2.15 -    "ReturnMistrustFprTests",
    2.16      "BlacklistTests",
    2.17      "RevokeRegenAttachTests",
    2.18      "PepSubjectReceivedTests",
    2.19 @@ -112,7 +110,7 @@
    2.20  };
    2.21  
    2.22  // This file is generated, so magic constants are ok.
    2.23 -int SuiteMaker::num_suites = 47;
    2.24 +int SuiteMaker::num_suites = 46;
    2.25  
    2.26  void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_home, Test::Suite** test_suite) {
    2.27      if (strcmp(test_class_name, "MimeTests") == 0)
    2.28 @@ -161,8 +159,6 @@
    2.29          *test_suite = new BlacklistAcceptNewKeyTests(test_class_name, test_home);
    2.30      else if (strcmp(test_class_name, "DecryptAttachPrivateKeyUntrustedTests") == 0)
    2.31          *test_suite = new DecryptAttachPrivateKeyUntrustedTests(test_class_name, test_home);
    2.32 -    else if (strcmp(test_class_name, "ReturnMistrustFprTests") == 0)
    2.33 -        *test_suite = new ReturnMistrustFprTests(test_class_name, test_home);
    2.34      else if (strcmp(test_class_name, "BlacklistTests") == 0)
    2.35          *test_suite = new BlacklistTests(test_class_name, test_home);
    2.36      else if (strcmp(test_class_name, "RevokeRegenAttachTests") == 0)