src/etpan_mime.c
branchpostrelease
changeset 4582 4f450d477709
parent 4581 780d3e087575
parent 4569 ee8bc2db141e
child 4590 448f18d446de
     1.1 --- a/src/etpan_mime.c	Wed Apr 22 10:33:06 2020 +0200
     1.2 +++ b/src/etpan_mime.c	Wed Apr 22 10:48:53 2020 +0200
     1.3 @@ -2524,6 +2524,26 @@
     1.4      return status;
     1.5  }
     1.6  
     1.7 +static bool _is_marked_as_attachment(struct mailmime_fields *fields)
     1.8 +{
     1.9 +    if (!(fields && fields->fld_list))
    1.10 +        return false;
    1.11 +
    1.12 +    clistiter *cur;
    1.13 +    for (cur = clist_begin(fields->fld_list); cur != NULL ; cur = clist_next(cur)) {
    1.14 +        struct mailmime_field * field = clist_content(cur);
    1.15 +        if (!(field && field->fld_type == MAILMIME_FIELD_DISPOSITION &&
    1.16 +                    field->fld_data.fld_disposition &&
    1.17 +                    field->fld_data.fld_disposition->dsp_type))
    1.18 +            continue;
    1.19 +        if (field->fld_data.fld_disposition->dsp_type->dsp_type ==
    1.20 +                MAILMIME_DISPOSITION_TYPE_ATTACHMENT)
    1.21 +            return true;
    1.22 +    }
    1.23 +
    1.24 +    return false;
    1.25 +}
    1.26 +
    1.27  static PEP_STATUS interpret_MIME(
    1.28          struct mailmime *mime,
    1.29          message *msg,
    1.30 @@ -2535,6 +2555,7 @@
    1.31      assert(mime);
    1.32      assert(msg);
    1.33  
    1.34 +    struct mailmime_fields *fields = mime->mm_mime_fields;
    1.35      struct mailmime_content *content = mime->mm_content_type;
    1.36      if (content) {
    1.37          if (_is_multipart(content, "alternative")) {
    1.38 @@ -2624,8 +2645,9 @@
    1.39          }
    1.40          else {
    1.41              if (_is_text_part(content, "html") &&
    1.42 -                msg->longmsg_formatted == NULL &&
    1.43 -                msg->longmsg == NULL) {
    1.44 +                    !_is_marked_as_attachment(fields) &&
    1.45 +                    msg->longmsg_formatted == NULL &&
    1.46 +                    msg->longmsg == NULL) {
    1.47                  status = interpret_body(mime, &msg->longmsg_formatted,
    1.48                                          NULL);
    1.49                  if (status)
    1.50 @@ -2637,14 +2659,16 @@
    1.51                      return status;
    1.52              }
    1.53              else if (_is_text_part(content, "plain") && 
    1.54 -                     msg->longmsg == NULL && msg->longmsg_formatted == NULL) {
    1.55 +                    !_is_marked_as_attachment(fields) &&
    1.56 +                    msg->longmsg == NULL && msg->longmsg_formatted == NULL) {
    1.57                  status = interpret_body(mime, &msg->longmsg, NULL);
    1.58                  if (status)
    1.59                      return status;
    1.60              }            
    1.61              else if (_is_text_part(content, NULL) && 
    1.62 -                     !_is_text_part(content, "plain") &&
    1.63 -                     msg->longmsg == NULL) {
    1.64 +                    !_is_marked_as_attachment(fields) &&
    1.65 +                    !_is_text_part(content, "plain") &&
    1.66 +                    msg->longmsg == NULL) {
    1.67                  status = interpret_body(mime, &msg->longmsg, NULL);
    1.68                  if (status)
    1.69                      return status;