merged in ENGINE-553 ENGINE-551
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Thu, 16 May 2019 18:03:03 +0200
branchENGINE-551
changeset 371770160ef539c2
parent 3712 2af31507d5d8
parent 3716 55f1a6d89704
child 3724 c878a420db18
merged in ENGINE-553
     1.1 --- a/src/aux_mime_msg.c	Thu May 16 17:54:28 2019 +0200
     1.2 +++ b/src/aux_mime_msg.c	Thu May 16 18:03:03 2019 +0200
     1.3 @@ -73,7 +73,7 @@
     1.4      message* dec_msg = NULL;
     1.5      *mime_plaintext = NULL;
     1.6  
     1.7 -    status = mime_decode_message(mimetext, size, &tmp_msg);
     1.8 +    status = mime_decode_message(mimetext, size, &tmp_msg, NULL);
     1.9      if (status != PEP_STATUS_OK)
    1.10          goto pEp_error;
    1.11  
    1.12 @@ -120,7 +120,7 @@
    1.13      }
    1.14  
    1.15      if (*flags & PEP_decrypt_flag_src_modified) {
    1.16 -        _mime_encode_message_internal(tmp_msg, false, modified_src, true);
    1.17 +        _mime_encode_message_internal(tmp_msg, false, modified_src, true, false);
    1.18          if (!modified_src) {
    1.19              *flags &= (~PEP_decrypt_flag_src_modified);
    1.20              decrypt_status = PEP_CANNOT_REENCRYPT; // Because we couldn't return it, I guess.
    1.21 @@ -128,7 +128,7 @@
    1.22      }
    1.23  
    1.24      // FIXME: test with att
    1.25 -    status = _mime_encode_message_internal(dec_msg, false, mime_plaintext, true);
    1.26 +    status = _mime_encode_message_internal(dec_msg, false, mime_plaintext, true, false);
    1.27  
    1.28      if (status == PEP_STATUS_OK)
    1.29      {
    1.30 @@ -159,7 +159,7 @@
    1.31      message* tmp_msg = NULL;
    1.32      message* enc_msg = NULL;
    1.33  
    1.34 -    status = mime_decode_message(mimetext, size, &tmp_msg);
    1.35 +    status = mime_decode_message(mimetext, size, &tmp_msg, NULL);
    1.36      if (status != PEP_STATUS_OK)
    1.37          goto pEp_error;
    1.38  
    1.39 @@ -214,7 +214,7 @@
    1.40          goto pEp_error;
    1.41      }
    1.42  
    1.43 -    status = _mime_encode_message_internal(enc_msg, false, mime_ciphertext, false);
    1.44 +    status = _mime_encode_message_internal(enc_msg, false, mime_ciphertext, false, false);
    1.45  
    1.46  pEp_error:
    1.47      free_message(tmp_msg);
    1.48 @@ -239,7 +239,7 @@
    1.49      message* tmp_msg = NULL;
    1.50      message* enc_msg = NULL;
    1.51  
    1.52 -    status = mime_decode_message(mimetext, size, &tmp_msg);
    1.53 +    status = mime_decode_message(mimetext, size, &tmp_msg, NULL);
    1.54      if (status != PEP_STATUS_OK)
    1.55          goto pEp_error;
    1.56  
    1.57 @@ -271,4 +271,3 @@
    1.58  #else
    1.59  const int the_answer_my_friend = 42;
    1.60  #endif
    1.61 -
     2.1 --- a/src/etpan_mime.c	Thu May 16 17:54:28 2019 +0200
     2.2 +++ b/src/etpan_mime.c	Thu May 16 18:03:03 2019 +0200
     2.3 @@ -38,6 +38,7 @@
     2.4  struct mailmime * part_new_empty(
     2.5          struct mailmime_content * content,
     2.6          struct mailmime_fields * mime_fields,
     2.7 +        stringpair_list_t* param_keyvals,
     2.8          int force_single
     2.9      )
    2.10  {
    2.11 @@ -127,6 +128,40 @@
    2.12          if (content->ct_parameters == NULL)
    2.13              content->ct_parameters = parameters;
    2.14      }
    2.15 +    
    2.16 +    if (param_keyvals) {
    2.17 +        stringpair_list_t* cur;
    2.18 +        for (cur = param_keyvals; cur; cur = cur->next) {
    2.19 +            attr_name = strdup(cur->value->key);
    2.20 +            attr_value = strdup(cur->value->value);
    2.21 +            
    2.22 +            param = mailmime_parameter_new(attr_name, attr_value);
    2.23 +            assert(param);
    2.24 +            if (param == NULL)
    2.25 +                goto enomem;
    2.26 +                
    2.27 +            attr_name = NULL;
    2.28 +            attr_value = NULL;
    2.29 +
    2.30 +            if (content->ct_parameters == NULL) {
    2.31 +                parameters = clist_new();
    2.32 +                assert(parameters);
    2.33 +                if (parameters == NULL)
    2.34 +                    goto enomem;
    2.35 +            }
    2.36 +            else {
    2.37 +                parameters = content->ct_parameters;
    2.38 +            }
    2.39 +
    2.40 +            r = clist_append(parameters, param);
    2.41 +            if (r)
    2.42 +                goto enomem;
    2.43 +            param = NULL;
    2.44 +
    2.45 +            if (content->ct_parameters == NULL)
    2.46 +                content->ct_parameters = parameters;            
    2.47 +        }
    2.48 +    }
    2.49  
    2.50      build_info = mailmime_new(mime_type, NULL, 0, mime_fields, content, NULL,
    2.51              NULL, NULL, list, NULL, NULL);
    2.52 @@ -163,7 +198,7 @@
    2.53      if (mime_fields == NULL)
    2.54          goto enomem;
    2.55  
    2.56 -    mime = part_new_empty(content, mime_fields, 1);
    2.57 +    mime = part_new_empty(content, mime_fields, NULL, 1);
    2.58      if (mime == NULL)
    2.59          goto enomem;
    2.60      mime_fields = NULL;
    2.61 @@ -252,7 +287,7 @@
    2.62              goto enomem;
    2.63      }
    2.64  
    2.65 -    mime = part_new_empty(content, mime_fields, 1);
    2.66 +    mime = part_new_empty(content, mime_fields, NULL, 1);
    2.67      if (mime == NULL)
    2.68          goto enomem;
    2.69      content = NULL;
    2.70 @@ -289,7 +324,8 @@
    2.71          const char * mime_type,
    2.72          char * data,
    2.73          size_t length,
    2.74 -        bool transport_encode
    2.75 +        bool transport_encode,
    2.76 +        bool set_attachment_forward_comment
    2.77      )
    2.78  {
    2.79      char * disposition_name = NULL;
    2.80 @@ -351,7 +387,13 @@
    2.81      encoding = NULL;
    2.82      disposition = NULL;
    2.83  
    2.84 -    mime = part_new_empty(content, mime_fields, 1);
    2.85 +    stringpair_list_t* extra_params = NULL;
    2.86 +    
    2.87 +    if (set_attachment_forward_comment)
    2.88 +        extra_params = new_stringpair_list(new_stringpair("forward", "no"));
    2.89 +    
    2.90 +    mime = part_new_empty(content, mime_fields, extra_params, 1);
    2.91 +    free_stringpair_list(extra_params);
    2.92      if (mime == NULL)
    2.93          goto enomem;
    2.94      content = NULL;
    2.95 @@ -396,7 +438,7 @@
    2.96      if (content == NULL)
    2.97          goto enomem;
    2.98      
    2.99 -    mp = part_new_empty(content, mime_fields, 0);
   2.100 +    mp = part_new_empty(content, mime_fields, NULL, 0);
   2.101      if (mp == NULL)
   2.102          goto enomem;
   2.103      
   2.104 @@ -815,6 +857,22 @@
   2.105      return false;
   2.106  }
   2.107  
   2.108 +bool _is_message_part(struct mailmime_content *content, const char* subtype) {
   2.109 +    assert(content);
   2.110 +    if (content->ct_type && content->ct_type->tp_type == MAILMIME_TYPE_COMPOSITE_TYPE &&
   2.111 +            content->ct_type->tp_data.tp_composite_type &&
   2.112 +            content->ct_type->tp_data.tp_composite_type->ct_type ==
   2.113 +            MAILMIME_COMPOSITE_TYPE_MESSAGE) {
   2.114 +        if (subtype)
   2.115 +            return content->ct_subtype &&
   2.116 +                    strcasecmp(content->ct_subtype, subtype) == 0;
   2.117 +        else
   2.118 +            return true;                
   2.119 +    }
   2.120 +    
   2.121 +    return false;
   2.122 +}
   2.123 +
   2.124  int _get_content_type(
   2.125          const struct mailmime_content *content,
   2.126          char **type,
   2.127 @@ -948,7 +1006,8 @@
   2.128  #endif
   2.129  
   2.130  static PEP_STATUS interpret_MIME(struct mailmime *mime,
   2.131 -                                 message *msg);
   2.132 +                                 message *msg,
   2.133 +                                 bool* raise_msg_attachment);
   2.134  
   2.135  // This function was rewritten to use in-memory buffers instead of
   2.136  // temporary files when the pgp/mime support was implemented for
   2.137 @@ -1006,7 +1065,8 @@
   2.138  static PEP_STATUS mime_attachment(
   2.139          bloblist_t *blob,
   2.140          struct mailmime **result,
   2.141 -        bool transport_encode
   2.142 +        bool transport_encode,
   2.143 +        bool set_attachment_forward_comment
   2.144      )
   2.145  {
   2.146      PEP_STATUS status = PEP_STATUS_OK;
   2.147 @@ -1031,7 +1091,8 @@
   2.148      bool already_ascii = !(must_chunk_be_encoded(blob->value, blob->size, true));
   2.149  
   2.150      mime = get_file_part(resource, mime_type, blob->value, blob->size, 
   2.151 -                          (already_ascii ? false : transport_encode));
   2.152 +                          (already_ascii ? false : transport_encode),
   2.153 +                          set_attachment_forward_comment);
   2.154      free_rid_list(resource);
   2.155      
   2.156      assert(mime);
   2.157 @@ -1155,7 +1216,7 @@
   2.158      for (_a = attachments; _a != NULL; _a = _a->next) {
   2.159          if (_a->disposition != PEP_CONTENT_DISP_INLINE)
   2.160              continue;
   2.161 -        status = mime_attachment(_a, &submime, transport_encode);
   2.162 +        status = mime_attachment(_a, &submime, transport_encode, false);
   2.163          if (status != PEP_STATUS_OK)
   2.164              return PEP_UNKNOWN_ERROR; // FIXME
   2.165  
   2.166 @@ -1632,7 +1693,8 @@
   2.167          const message *msg,
   2.168          bool omit_fields,
   2.169          struct mailmime **result,
   2.170 -        bool transport_encode
   2.171 +        bool transport_encode,
   2.172 +        bool set_attachment_forward_comment
   2.173      )
   2.174  {
   2.175      struct mailmime * mime = NULL;
   2.176 @@ -1711,14 +1773,19 @@
   2.177          }
   2.178  
   2.179          bloblist_t *_a;
   2.180 +        bool first_one = true;
   2.181 +        
   2.182          for (_a = msg->attachments; _a != NULL; _a = _a->next) {
   2.183  
   2.184              if (_a->disposition == PEP_CONTENT_DISP_INLINE)
   2.185                  continue;
   2.186  
   2.187 -            status = mime_attachment(_a, &submime, transport_encode);
   2.188 +            status = mime_attachment(_a, &submime, transport_encode,
   2.189 +                                     (first_one && set_attachment_forward_comment));                         
   2.190              if (status != PEP_STATUS_OK)
   2.191                  goto pEp_error;
   2.192 +            
   2.193 +            first_one = false;    
   2.194  
   2.195              r = mailmime_smart_add_part(mime, submime);
   2.196              assert(r == MAILIMF_NO_ERROR);
   2.197 @@ -1830,7 +1897,8 @@
   2.198          const message * msg,
   2.199          bool omit_fields,
   2.200          char **mimetext,
   2.201 -        bool transport_encode
   2.202 +        bool transport_encode,
   2.203 +        bool set_attachment_forward_comment
   2.204      )
   2.205  {
   2.206      PEP_STATUS status = PEP_STATUS_OK;
   2.207 @@ -1850,11 +1918,12 @@
   2.208  
   2.209      switch (msg->enc_format) {
   2.210          case PEP_enc_none:
   2.211 -            status = mime_encode_message_plain(msg, omit_fields, &mime, transport_encode);
   2.212 +            status = mime_encode_message_plain(msg, omit_fields, &mime, transport_encode, set_attachment_forward_comment);
   2.213              break;
   2.214  
   2.215 +        // I'm presuming we should hardcore ignoring set_attachment_forward_comment here...
   2.216          case PEP_enc_inline:
   2.217 -            status = mime_encode_message_plain(msg, omit_fields, &mime, transport_encode);
   2.218 +            status = mime_encode_message_plain(msg, omit_fields, &mime, transport_encode, false);
   2.219              break;
   2.220  
   2.221          case PEP_enc_S_MIME:
   2.222 @@ -2402,7 +2471,7 @@
   2.223          // ???
   2.224          // This is what we would have done before, so... no
   2.225          // worse than the status quo. But FIXME!
   2.226 -        status = interpret_MIME(part, msg);
   2.227 +        status = interpret_MIME(part, msg, NULL);
   2.228          if (status)
   2.229              return status;
   2.230      }
   2.231 @@ -2417,7 +2486,7 @@
   2.232          if (content == NULL)
   2.233              return PEP_ILLEGAL_VALUE;
   2.234  
   2.235 -        status = interpret_MIME(part, msg);
   2.236 +        status = interpret_MIME(part, msg, NULL);
   2.237          if (status)
   2.238              return status;
   2.239      }
   2.240 @@ -2426,7 +2495,8 @@
   2.241  
   2.242  static PEP_STATUS interpret_MIME(
   2.243          struct mailmime *mime,
   2.244 -        message *msg
   2.245 +        message *msg,
   2.246 +        bool* raise_msg_attachment
   2.247      )
   2.248  {
   2.249      PEP_STATUS status = PEP_STATUS_OK;
   2.250 @@ -2476,7 +2546,7 @@
   2.251                          return status;
   2.252                  }
   2.253                  else /* add as attachment */ {
   2.254 -                    status = interpret_MIME(part, msg);
   2.255 +                    status = interpret_MIME(part, msg, NULL);
   2.256                      if (status)
   2.257                          return status;
   2.258                  }
   2.259 @@ -2499,7 +2569,7 @@
   2.260                  if (part == NULL)
   2.261                      return PEP_ILLEGAL_VALUE;
   2.262  
   2.263 -                status = interpret_MIME(part, msg);
   2.264 +                status = interpret_MIME(part, msg, NULL);
   2.265                  if (status != PEP_STATUS_OK)
   2.266                      return status;
   2.267              }
   2.268 @@ -2510,11 +2580,13 @@
   2.269                  return PEP_ILLEGAL_VALUE;
   2.270  
   2.271              clistiter *cur;
   2.272 -            for (cur = clist_begin(partlist); cur; cur = clist_next(cur)) {
   2.273 +            // only add raise_msg_attachment on 2nd part!
   2.274 +            int _att_count = 0;
   2.275 +            for (cur = clist_begin(partlist); cur; cur = clist_next(cur), _att_count++) {
   2.276                  struct mailmime *part= clist_content(cur);
   2.277                  if (part == NULL)
   2.278                      return PEP_ILLEGAL_VALUE;
   2.279 -                status = interpret_MIME(part, msg);
   2.280 +                status = interpret_MIME(part, msg, _att_count == 1 ? raise_msg_attachment : NULL);
   2.281                  if (status != PEP_STATUS_OK)
   2.282                      return status;
   2.283              }
   2.284 @@ -2547,6 +2619,25 @@
   2.285                      return status;
   2.286              }
   2.287              else {
   2.288 +                // Fixme - we need a control on recursion level here - KG: maybe NOT. We only go to depth 1.
   2.289 +                if (raise_msg_attachment != NULL) {
   2.290 +                    bool is_msg = (_is_message_part(content, "rfc822") || _is_text_part(content, "rfc822"));
   2.291 +                    if (is_msg) {
   2.292 +                        if (content->ct_parameters) {
   2.293 +                            clistiter *cur;
   2.294 +                            for (cur = clist_begin(content->ct_parameters); cur; cur =
   2.295 +                                 clist_next(cur)) {
   2.296 +                                struct mailmime_parameter * param = clist_content(cur);
   2.297 +                                if (param && param->pa_name && strcasecmp(param->pa_name, "forward") == 0) {
   2.298 +                                    if (param->pa_value && strcasecmp(param->pa_value, "no") == 0) {
   2.299 +                                        *raise_msg_attachment = true;
   2.300 +                                        break;
   2.301 +                                    }
   2.302 +                                }
   2.303 +                            }
   2.304 +                        }
   2.305 +                    }
   2.306 +                }
   2.307                  char *data = NULL;
   2.308                  size_t size = 0;
   2.309                  char * mime_type;
   2.310 @@ -2633,7 +2724,8 @@
   2.311  DYNAMIC_API PEP_STATUS mime_decode_message(
   2.312          const char *mimetext,
   2.313          size_t size,
   2.314 -        message **msg
   2.315 +        message **msg,
   2.316 +        bool* raise_msg_attachment
   2.317      )
   2.318  {
   2.319      PEP_STATUS status = PEP_STATUS_OK;
   2.320 @@ -2677,7 +2769,7 @@
   2.321  
   2.322      if (content) {
   2.323          status = interpret_MIME(mime->mm_data.mm_message.mm_msg_mime,
   2.324 -                _msg);
   2.325 +                _msg, raise_msg_attachment);
   2.326          if (status != PEP_STATUS_OK)
   2.327              goto pEp_error;
   2.328      }
   2.329 @@ -2702,4 +2794,3 @@
   2.330  
   2.331      return status;
   2.332  }
   2.333 -
     3.1 --- a/src/etpan_mime.h	Thu May 16 17:54:28 2019 +0200
     3.2 +++ b/src/etpan_mime.h	Thu May 16 18:03:03 2019 +0200
     3.3 @@ -8,10 +8,12 @@
     3.4  #include <libetpan/mailmime_encode.h>
     3.5  
     3.6  #include "resource_id.h"
     3.7 +#include "stringpair.h"
     3.8  
     3.9  struct mailmime * part_new_empty(
    3.10          struct mailmime_content * content,
    3.11          struct mailmime_fields * mime_fields,
    3.12 +        stringpair_list_t* param_keyvals,        
    3.13          int force_single
    3.14      );
    3.15  
    3.16 @@ -30,7 +32,8 @@
    3.17          const char * mime_type,
    3.18          char * data,
    3.19          size_t length,
    3.20 -        bool transport_encode
    3.21 +        bool transport_encode,
    3.22 +        bool set_attachment_forward_comment
    3.23      );
    3.24  
    3.25  struct mailmime * part_multiple_new(const char *type);
     4.1 --- a/src/message.h	Thu May 16 17:54:28 2019 +0200
     4.2 +++ b/src/message.h	Thu May 16 18:03:03 2019 +0200
     4.3 @@ -70,6 +70,9 @@
     4.4      char *comments;                         // UTF-8 string with comments
     4.5      stringpair_list_t *opt_fields;          // optional fields
     4.6      PEP_enc_format enc_format;              // format of encrypted data
     4.7 +    char* _sender_fpr;                      // INTERNAL USE ONLY - fingerprint of 
     4.8 +                                            // sending signer.
     4.9 +                                            // (read_only to the outside)
    4.10  } message;
    4.11  
    4.12  typedef struct _message_ref_list {
     5.1 --- a/src/message_api.c	Thu May 16 17:54:28 2019 +0200
     5.2 +++ b/src/message_api.c	Thu May 16 18:03:03 2019 +0200
     5.3 @@ -916,10 +916,14 @@
     5.4              default:
     5.5                  inner_type_string = "INNER";
     5.6          }
     5.7 -        attachment->longmsg = encapsulate_message_wrap_info(inner_type_string, attachment->longmsg);
     5.8 +        attachment->longmsg = encapsulate_message_wrap_info(inner_type_string, attachment->longmsg);        
     5.9          _envelope->longmsg = encapsulate_message_wrap_info("OUTER", _envelope->longmsg);
    5.10 +
    5.11 +        // 2.1, to replace the above
    5.12 +        add_opt_field(attachment, PEP_MSG_WRAP_KEY, inner_type_string); 
    5.13      }
    5.14      else if (_envelope) {
    5.15 +        // 2.1 - how do we peel this particular union when we get there?
    5.16          _envelope->longmsg = encapsulate_message_wrap_info("TRANSPORT", _envelope->longmsg);
    5.17      }
    5.18      else {
    5.19 @@ -947,9 +951,15 @@
    5.20          if (!attachment->shortmsg)
    5.21              goto enomem;
    5.22      }
    5.23 +    
    5.24 +    /* add sender fpr to inner message */
    5.25 +    add_opt_field(attachment, 
    5.26 +                  "X-pEp-Sender-FPR", 
    5.27 +                  (attachment->_sender_fpr ? attachment->_sender_fpr : "")
    5.28 +              );
    5.29              
    5.30      /* Turn message into a MIME-blob */
    5.31 -    status = _mime_encode_message_internal(attachment, false, &message_text, true);
    5.32 +    status = _mime_encode_message_internal(attachment, false, &message_text, true, false);
    5.33          
    5.34      if (status != PEP_STATUS_OK)
    5.35          goto enomem;
    5.36 @@ -1053,8 +1063,11 @@
    5.37      _src->longmsg_formatted = src->longmsg_formatted;
    5.38      _src->attachments = src->attachments;
    5.39      _src->enc_format = PEP_enc_none;
    5.40 -    bool mime_encode = !is_wrapper(_src);
    5.41 -    status = _mime_encode_message_internal(_src, true, &mimetext, mime_encode);
    5.42 +    
    5.43 +    // These vars are here to be clear, and because I don't know how this may change in the near future.
    5.44 +    bool wrapped = is_wrapper(_src);
    5.45 +    bool mime_encode = !wrapped;
    5.46 +    status = _mime_encode_message_internal(_src, true, &mimetext, mime_encode, wrapped);
    5.47      assert(status == PEP_STATUS_OK);
    5.48      if (status != PEP_STATUS_OK)
    5.49          goto pEp_error;
    5.50 @@ -1730,7 +1743,10 @@
    5.51      if (status != PEP_STATUS_OK)
    5.52          goto pEp_error;
    5.53  
    5.54 -    keys = new_stringlist(src->from->fpr);
    5.55 +    char* send_fpr = strdup(src->from->fpr ? src->from->fpr : "");
    5.56 +    src->_sender_fpr = send_fpr;
    5.57 +    
    5.58 +    keys = new_stringlist(send_fpr);
    5.59      if (keys == NULL)
    5.60          goto enomem;
    5.61  
    5.62 @@ -3465,6 +3481,7 @@
    5.63      decrypt_status = status;
    5.64      
    5.65      bool imported_private_key_address = false;
    5.66 +    bool has_inner = false;
    5.67  
    5.68      if (ptext) { 
    5.69          /* we got a plaintext from decryption */
    5.70 @@ -3473,7 +3490,7 @@
    5.71              case PEP_enc_PGP_MIME:
    5.72              case PEP_enc_PGP_MIME_Outlook1:
    5.73              
    5.74 -                status = mime_decode_message(ptext, psize, &msg);
    5.75 +                status = mime_decode_message(ptext, psize, &msg, &has_inner);
    5.76                  if (status != PEP_STATUS_OK)
    5.77                      goto pEp_error;
    5.78                  
    5.79 @@ -3549,129 +3566,176 @@
    5.80          if (decrypt_status == PEP_DECRYPTED || decrypt_status == PEP_DECRYPTED_AND_VERIFIED) {
    5.81              char* wrap_info = NULL;
    5.82              
    5.83 -            status = unencapsulate_hidden_fields(src, msg, &wrap_info);
    5.84 +            if (!has_inner)
    5.85 +                status = unencapsulate_hidden_fields(src, msg, &wrap_info);
    5.86  
    5.87  //            bool is_transport_wrapper = false;
    5.88              
    5.89 +        
    5.90              // FIXME: replace with enums, check status
    5.91 -            if (wrap_info) {
    5.92 -                if (strcmp(wrap_info, "OUTER") == 0) {
    5.93 -                    // this only occurs in with a direct outer wrapper
    5.94 -                    // where the actual content is in the inner wrapper
    5.95 -                    message* inner_message = NULL;                    
    5.96 +            if (has_inner || wrap_info) { // Given that only wrap_info OUTER happens as of the end of wrap_info use, we don't need to strcmp it
    5.97 +                // if (strcmp(wrap_info, "OUTER") == 0) {
    5.98 +                //     // this only occurs in with a direct outer wrapper
    5.99 +                //     // where the actual content is in the inner wrapper
   5.100 +                message* inner_message = NULL;
   5.101 +                    
   5.102 +                // For a wrapped message, this is ALWAYS the second attachment; the 
   5.103 +                // mime tree is:
   5.104 +                // multipart/mixed
   5.105 +                //     |
   5.106 +                //     |----- text/plain 
   5.107 +                //     |----- message/rfc822
   5.108 +                //     |----- ...
   5.109 +                //
   5.110 +                // We leave this in below, but once we're rid of 2.0 format,
   5.111 +                // we can dispense with the loop, as has_inner -> 1st message struct attachment is message/rfc822
   5.112 +                //                   
   5.113 +
   5.114 +                bloblist_t* message_blob = msg->attachments;
   5.115 +                                    
   5.116 +                if (msg->attachments) {
   5.117 +                    message_blob = msg->attachments;
   5.118 +                    if (!has_inner && strcmp(message_blob->mime_type, "message/rfc822") != 0
   5.119 +                                   && strcmp(message_blob->mime_type, "text/rfc822") != 0)
   5.120 +                        message_blob = NULL;
   5.121 +                }
   5.122 +                    
   5.123 +                if (!message_blob) {
   5.124                      bloblist_t* actual_message = msg->attachments;
   5.125 -                    
   5.126 +                
   5.127                      while (actual_message) {
   5.128                          char* mime_type = actual_message->mime_type;
   5.129                          if (mime_type) {
   5.130 -                            
   5.131 +                        
   5.132                              // libetpan appears to change the mime_type on this one.
   5.133                              // *growl*
   5.134                              if (strcmp("message/rfc822", mime_type) == 0 ||
   5.135                                  strcmp("text/rfc822", mime_type) == 0) {
   5.136 -                                    
   5.137 -                                status = mime_decode_message(actual_message->value, 
   5.138 -                                                             actual_message->size, 
   5.139 -                                                             &inner_message);
   5.140 -                                if (status != PEP_STATUS_OK)
   5.141 -                                    goto pEp_error;
   5.142 +                                message_blob = actual_message;
   5.143 +                                break;
   5.144 +                            }
   5.145 +                        }
   5.146 +                        actual_message = actual_message->next;
   5.147 +                    }        
   5.148 +                }    
   5.149 +                if (message_blob) {              
   5.150 +                    status = mime_decode_message(message_blob->value, 
   5.151 +                                                 message_blob->size, 
   5.152 +                                                 &inner_message,
   5.153 +                                                 NULL);
   5.154 +                    if (status != PEP_STATUS_OK)
   5.155 +                        goto pEp_error;
   5.156                                  
   5.157 -                                if (inner_message) {
   5.158 -                                    // Though this will strip any message info on the
   5.159 -                                    // attachment, this is safe, as we do not
   5.160 -                                    // produce more than one attachment-as-message,
   5.161 -                                    // and those are the only ones with such info.
   5.162 -                                    // Since we capture the information, this is ok.
   5.163 -                                    wrap_info = NULL;
   5.164 -                                    inner_message->enc_format = src->enc_format;
   5.165 -                                    // FIXME
   5.166 -                                    status = unencapsulate_hidden_fields(inner_message, NULL, &wrap_info);
   5.167 -                                    
   5.168 -                                    // ?
   5.169 +                    if (inner_message) {
   5.170 +                        // Though this will strip any message info on the
   5.171 +                        // attachment, this is safe, as we do not
   5.172 +                        // produce more than one attachment-as-message,
   5.173 +                        // and those are the only ones with such info.
   5.174 +                        // Since we capture the information, this is ok.
   5.175 +                        wrap_info = NULL;
   5.176 +                        inner_message->enc_format = src->enc_format;
   5.177 +
   5.178 +                        const stringpair_list_t* pEp_protocol_version = NULL;
   5.179 +                        const stringpair_list_t* sender_fpr = NULL;
   5.180 +                        pEp_protocol_version = stringpair_list_find(inner_message->opt_fields, "X-pEp-Version");
   5.181 +                        unsigned int pEp_v_major = 0;
   5.182 +                        unsigned int pEp_v_minor = 0;
   5.183 +                        if (pEp_protocol_version && !EMPTYSTR(pEp_protocol_version->value->value)) {
   5.184 +                            // Roker is of course right. Meh :)
   5.185 +                            if (sscanf(pEp_protocol_version->value->value, "%u.%u", &pEp_v_major, &pEp_v_minor) != 2) {
   5.186 +                                pEp_v_major = 0;
   5.187 +                                pEp_v_minor = 0;
   5.188 +                            }
   5.189 +                        }
   5.190 +                            
   5.191 +                        if (((pEp_v_major == 2) && (pEp_v_minor > 0)) || (pEp_v_major > 2))                              
   5.192 +                            sender_fpr = stringpair_list_find(inner_message->opt_fields, "X-pEp-Sender-FPR");
   5.193 +
   5.194 +                        // FIXME - Message 2.1                                    
   5.195 +                        status = unencapsulate_hidden_fields(inner_message, NULL, &wrap_info);                            
   5.196 +                        
   5.197 +                        // ?
   5.198 +                        if (status != PEP_STATUS_OK) {
   5.199 +                            free_message(inner_message);
   5.200 +                            goto pEp_error;
   5.201 +                        }
   5.202 +
   5.203 +                        if (wrap_info) {
   5.204 +                            bool is_inner = (strcmp(wrap_info, "INNER") == 0);
   5.205 +                            bool is_key_reset = (strcmp(wrap_info, "KEY_RESET") == 0);
   5.206 +
   5.207 +                            if (is_key_reset) {
   5.208 +                                if (decrypt_status == PEP_DECRYPTED || decrypt_status == PEP_DECRYPTED_AND_VERIFIED) {
   5.209 +                                    status = receive_key_reset(session,
   5.210 +                                                               inner_message);
   5.211                                      if (status != PEP_STATUS_OK) {
   5.212                                          free_message(inner_message);
   5.213                                          goto pEp_error;
   5.214                                      }
   5.215 -    
   5.216 -                                    if (wrap_info) {
   5.217 -                                        bool is_inner = (strcmp(wrap_info, "INNER") == 0);
   5.218 -                                        bool is_key_reset = (strcmp(wrap_info, "KEY_RESET") == 0);
   5.219 -
   5.220 -                                        if (is_key_reset) {
   5.221 -                                            if (decrypt_status == PEP_DECRYPTED || decrypt_status == PEP_DECRYPTED_AND_VERIFIED) {
   5.222 -                                                status = receive_key_reset(session,
   5.223 -                                                                           inner_message);
   5.224 -                                                if (status != PEP_STATUS_OK) {
   5.225 -                                                    free_message(inner_message);
   5.226 -                                                    goto pEp_error;
   5.227 -                                                }
   5.228 -                                                *flags |= PEP_decrypt_flag_consume;
   5.229 -                                            }
   5.230 -                                        }
   5.231 -                                        else if (is_inner) {
   5.232 -
   5.233 -                                            // check for private key in decrypted message attachment while importing
   5.234 -                                            // N.B. Apparently, we always import private keys into the keyring; however,
   5.235 -                                            // we do NOT always allow those to be used for encryption. THAT is controlled
   5.236 -                                            // by setting it as an own identity associated with the key in the DB.
   5.237 -                                            
   5.238 -                                            // If we have a message 2.0 message, we are ONLY going to be ok with keys
   5.239 -                                            // we imported from THIS part of the message.
   5.240 -                                            imported_private_key_address = false;
   5.241 -                                            free(private_il); 
   5.242 -                                            private_il = NULL;
   5.243 -                                            
   5.244 -                                            // import keys from decrypted INNER source
   5.245 -                                            status = import_priv_keys_from_decrypted_msg(session, inner_message,
   5.246 -                                                                                         &imported_keys,
   5.247 -                                                                                         &imported_private_key_address,
   5.248 -                                                                                         private_il);
   5.249 -                                            if (status != PEP_STATUS_OK)
   5.250 -                                                goto pEp_error;            
   5.251 -
   5.252 -                                            // THIS is our message
   5.253 -                                            // Now, let's make sure we've copied in 
   5.254 -                                            // any information sent in by the app if
   5.255 -                                            // needed...
   5.256 -                                            reconcile_src_and_inner_messages(src, inner_message);
   5.257 -                                            
   5.258 -
   5.259 -                                            // FIXME: free msg, but check references
   5.260 -                                            //src = msg = inner_message;
   5.261 -                                            calculated_src = msg = inner_message;
   5.262 -                                            
   5.263 -                                            // FIXME: should this be msg???
   5.264 -                                            if (src->from) {
   5.265 -                                                if (!is_me(session, src->from))
   5.266 -                                                    update_identity(session, (src->from));
   5.267 -                                                else
   5.268 -                                                    _myself(session, src->from, false, false, myself_read_only);
   5.269 -                                            }
   5.270 -                                            break;        
   5.271 -                                        }
   5.272 -                                        else { // should never happen
   5.273 -                                            status = PEP_UNKNOWN_ERROR;
   5.274 -                                            free_message(inner_message);
   5.275 -                                            goto pEp_error;
   5.276 -                                        }
   5.277 -                                    }
   5.278 -                                    inner_message->enc_format = PEP_enc_none;
   5.279 -                                }
   5.280 -                                else { // forwarded message, leave it alone
   5.281 -                                    free_message(inner_message);
   5.282 +                                    *flags |= PEP_decrypt_flag_consume;
   5.283                                  }
   5.284                              }
   5.285 +                            else if (is_inner) {
   5.286 +
   5.287 +                                // check for private key in decrypted message attachment while importing
   5.288 +                                // N.B. Apparently, we always import private keys into the keyring; however,
   5.289 +                                // we do NOT always allow those to be used for encryption. THAT is controlled
   5.290 +                                // by setting it as an own identity associated with the key in the DB.
   5.291 +                                
   5.292 +                                // If we have a message 2.0 message, we are ONLY going to be ok with keys
   5.293 +                                // we imported from THIS part of the message.
   5.294 +                                imported_private_key_address = false;
   5.295 +                                free(private_il); 
   5.296 +                                private_il = NULL;
   5.297 +                                
   5.298 +                                // import keys from decrypted INNER source
   5.299 +                                status = import_priv_keys_from_decrypted_msg(session, inner_message,
   5.300 +                                                                             &imported_keys,
   5.301 +                                                                             &imported_private_key_address,
   5.302 +                                                                             private_il);
   5.303 +                                if (status != PEP_STATUS_OK)
   5.304 +                                    goto pEp_error;            
   5.305 +
   5.306 +                                // THIS is our message
   5.307 +                                // Now, let's make sure we've copied in 
   5.308 +                                // any information sent in by the app if
   5.309 +                                // needed...
   5.310 +                                reconcile_src_and_inner_messages(src, inner_message);
   5.311 +                                
   5.312 +
   5.313 +                                // FIXME: free msg, but check references
   5.314 +                                //src = msg = inner_message;
   5.315 +                                calculated_src = msg = inner_message;
   5.316 +                                
   5.317 +                                // FIXME: should this be msg???
   5.318 +                                if (src->from) {
   5.319 +                                    if (!is_me(session, src->from))
   5.320 +                                        update_identity(session, (src->from));
   5.321 +                                    else
   5.322 +                                        _myself(session, src->from, false, false, myself_read_only);
   5.323 +                                }
   5.324 +                            }
   5.325 +                            else { // should never happen
   5.326 +                                status = PEP_UNKNOWN_ERROR;
   5.327 +                                free_message(inner_message);
   5.328 +                                goto pEp_error;
   5.329 +                            }
   5.330                          }
   5.331 -                        actual_message = actual_message->next;
   5.332 -                    }                    
   5.333 -                }
   5.334 -                else if (strcmp(wrap_info, "TRANSPORT") == 0) {
   5.335 -                    // FIXME: this gets even messier.
   5.336 -                    // (TBI in ENGINE-278)
   5.337 -                }
   5.338 -                else {} // shouldn't be anything to be done here
   5.339 -            }
   5.340 -        }
   5.341 +                        inner_message->enc_format = PEP_enc_none;
   5.342 +                    }
   5.343 +                    else { // forwarded message, leave it alone
   5.344 +                        free_message(inner_message);
   5.345 +                    }
   5.346 +                } // end if (message_blob)
   5.347 +                
   5.348 +                //  else if (strcmp(wrap_info, "TRANSPORT") == 0) {
   5.349 +                //      // FIXME: this gets even messier.
   5.350 +                //      // (TBI in ENGINE-278)
   5.351 +                //  }
   5.352 +                //  else {} // shouldn't be anything to be done here
   5.353 +    
   5.354 +            } // end if (has_inner || wrap_info)
   5.355 +        } // end if (decrypt_status == PEP_DECRYPTED || decrypt_status == PEP_DECRYPTED_AND_VERIFIED)
   5.356          
   5.357          *rating = decrypt_rating(decrypt_status);
   5.358          
     6.1 --- a/src/mime.c	Thu May 16 17:54:28 2019 +0200
     6.2 +++ b/src/mime.c	Thu May 16 18:03:03 2019 +0200
     6.3 @@ -39,6 +39,5 @@
     6.4          char **mimetext
     6.5      )
     6.6  {
     6.7 -    return _mime_encode_message_internal(msg, omit_fields, mimetext, true);
     6.8 +    return _mime_encode_message_internal(msg, omit_fields, mimetext, true, false);
     6.9  }
    6.10 -
     7.1 --- a/src/mime.h	Thu May 16 17:54:28 2019 +0200
     7.2 +++ b/src/mime.h	Thu May 16 18:03:03 2019 +0200
     7.3 @@ -75,7 +75,8 @@
     7.4  DYNAMIC_API PEP_STATUS mime_decode_message(
     7.5          const char *mimetext,
     7.6          size_t size,
     7.7 -        message **msg
     7.8 +        message **msg,
     7.9 +        bool* raise_msg_attachment
    7.10      );
    7.11  
    7.12  /* sometimes we don't want to transport encode */
    7.13 @@ -83,7 +84,8 @@
    7.14          const message * msg,
    7.15          bool omit_fields,
    7.16          char **mimetext,
    7.17 -        bool transport_encode
    7.18 +        bool transport_encode,
    7.19 +        bool set_attachment_forward_comment        
    7.20      );
    7.21  
    7.22  
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/test/include/SenderFPRTests.h	Thu May 16 18:03:03 2019 +0200
     8.3 @@ -0,0 +1,19 @@
     8.4 +// This file is under GNU General Public License 3.0
     8.5 +// see LICENSE.txt
     8.6 +
     8.7 +#ifndef SENDER_F_P_R_H
     8.8 +#define SENDER_F_P_R_H
     8.9 +
    8.10 +#include <string>
    8.11 +#include "EngineTestIndividualSuite.h"
    8.12 +
    8.13 +using namespace std;
    8.14 +
    8.15 +class SenderFPRTests : public EngineTestIndividualSuite {
    8.16 +    public:
    8.17 +        SenderFPRTests(string test_suite, string test_home_dir);
    8.18 +    private:
    8.19 +        void check_sender_f_p_r();
    8.20 +};
    8.21 +
    8.22 +#endif
     9.1 --- a/test/src/SuiteMaker.cc	Thu May 16 17:54:28 2019 +0200
     9.2 +++ b/test/src/SuiteMaker.cc	Thu May 16 18:03:03 2019 +0200
     9.3 @@ -22,6 +22,7 @@
     9.4  #include "BloblistTests.h"
     9.5  #include "NewUpdateIdAndMyselfTests.h"
     9.6  #include "NoOwnIdentWritesOnDecryptTests.h"
     9.7 +#include "LiteralFilenameTests.h"
     9.8  #include "I18nTests.h"
     9.9  #include "IdentityListTests.h"
    9.10  #include "PgpBinaryTests.h"
    9.11 @@ -69,6 +70,7 @@
    9.12  #include "OwnKeysRetrieveTests.h"
    9.13  #include "TrustManipulationTests.h"
    9.14  #include "SyncTests.h"
    9.15 +#include "SenderFPRTests.h"
    9.16  #include "RevocationTests.h"
    9.17  #include "AppleMailTests.h"
    9.18  
    9.19 @@ -84,6 +86,7 @@
    9.20      "BloblistTests",
    9.21      "NewUpdateIdAndMyselfTests",
    9.22      "NoOwnIdentWritesOnDecryptTests",
    9.23 +    "LiteralFilenameTests",
    9.24      "I18nTests",
    9.25      "IdentityListTests",
    9.26      "PgpBinaryTests",
    9.27 @@ -131,12 +134,13 @@
    9.28      "OwnKeysRetrieveTests",
    9.29      "TrustManipulationTests",
    9.30      "SyncTests",
    9.31 +    "SenderFPRTests",
    9.32      "RevocationTests",
    9.33      "AppleMailTests",
    9.34  };
    9.35  
    9.36  // This file is generated, so magic constants are ok.
    9.37 -int SuiteMaker::num_suites = 59;
    9.38 +int SuiteMaker::num_suites = 61;
    9.39  
    9.40  void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_home, Test::Suite** test_suite) {
    9.41      if (strcmp(test_class_name, "URIAddressTests") == 0)
    9.42 @@ -159,6 +163,8 @@
    9.43          *test_suite = new NewUpdateIdAndMyselfTests(test_class_name, test_home);
    9.44      else if (strcmp(test_class_name, "NoOwnIdentWritesOnDecryptTests") == 0)
    9.45          *test_suite = new NoOwnIdentWritesOnDecryptTests(test_class_name, test_home);
    9.46 +    else if (strcmp(test_class_name, "LiteralFilenameTests") == 0)
    9.47 +        *test_suite = new LiteralFilenameTests(test_class_name, test_home);
    9.48      else if (strcmp(test_class_name, "I18nTests") == 0)
    9.49          *test_suite = new I18nTests(test_class_name, test_home);
    9.50      else if (strcmp(test_class_name, "IdentityListTests") == 0)
    9.51 @@ -253,6 +259,8 @@
    9.52          *test_suite = new TrustManipulationTests(test_class_name, test_home);
    9.53      else if (strcmp(test_class_name, "SyncTests") == 0)
    9.54          *test_suite = new SyncTests(test_class_name, test_home);
    9.55 +    else if (strcmp(test_class_name, "SenderFPRTests") == 0)
    9.56 +        *test_suite = new SenderFPRTests(test_class_name, test_home);
    9.57      else if (strcmp(test_class_name, "RevocationTests") == 0)
    9.58          *test_suite = new RevocationTests(test_class_name, test_home);
    9.59      else if (strcmp(test_class_name, "AppleMailTests") == 0)
    10.1 --- a/test/src/engine_tests/AppleMailTests.cc	Thu May 16 17:54:28 2019 +0200
    10.2 +++ b/test/src/engine_tests/AppleMailTests.cc	Thu May 16 18:03:03 2019 +0200
    10.3 @@ -67,7 +67,7 @@
    10.4      PEP_decrypt_flags_t flags = 0;
    10.5      
    10.6      message* final_ptr = nullptr;
    10.7 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
    10.8 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
    10.9      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   10.10      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
   10.11      
   10.12 @@ -129,7 +129,7 @@
   10.13      const char* mailfile2 = "test_mails/apple_mail_TC_html_signed_encrypted.eml";
   10.14      const string mailtext2 = slurp(mailfile2);
   10.15      
   10.16 -    status = mime_decode_message(mailtext2.c_str(), mailtext2.length(), &msg_ptr);
   10.17 +    status = mime_decode_message(mailtext2.c_str(), mailtext2.length(), &msg_ptr, NULL);
   10.18      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   10.19      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
   10.20      final_ptr = msg_ptr;
    11.1 --- a/test/src/engine_tests/BlacklistAcceptNewKeyTests.cc	Thu May 16 17:54:28 2019 +0200
    11.2 +++ b/test/src/engine_tests/BlacklistAcceptNewKeyTests.cc	Thu May 16 18:03:03 2019 +0200
    11.3 @@ -80,7 +80,7 @@
    11.4      PEP_rating rating;
    11.5      PEP_decrypt_flags_t flags = 0;
    11.6      
    11.7 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
    11.8 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
    11.9      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   11.10      status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
   11.11  
    12.1 --- a/test/src/engine_tests/EncryptForIdentityTests.cc	Thu May 16 17:54:28 2019 +0200
    12.2 +++ b/test/src/engine_tests/EncryptForIdentityTests.cc	Thu May 16 18:03:03 2019 +0200
    12.3 @@ -96,7 +96,7 @@
    12.4      cout << encoded_text << "\n";
    12.5  
    12.6      message* decoded_msg = nullptr;
    12.7 -    status = mime_decode_message(encoded_text, strlen(encoded_text), &decoded_msg);
    12.8 +    status = mime_decode_message(encoded_text, strlen(encoded_text), &decoded_msg, NULL);
    12.9      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   12.10      const string string3 = encoded_text;
   12.11  
    13.1 --- a/test/src/engine_tests/EncryptMissingPrivateKeyTests.cc	Thu May 16 17:54:28 2019 +0200
    13.2 +++ b/test/src/engine_tests/EncryptMissingPrivateKeyTests.cc	Thu May 16 18:03:03 2019 +0200
    13.3 @@ -55,7 +55,7 @@
    13.4      
    13.5      const string mailtext = slurp("test_mails/blacklist_no_key.eml");
    13.6  
    13.7 -    PEP_STATUS status = mime_decode_message(mailtext.c_str(), mailtext.length(), &tmp_msg);
    13.8 +    PEP_STATUS status = mime_decode_message(mailtext.c_str(), mailtext.length(), &tmp_msg, NULL);
    13.9      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   13.10      
   13.11      status = update_identity(session, tmp_msg->from);
    14.1 --- a/test/src/engine_tests/KeyAttachmentTests.cc	Thu May 16 17:54:28 2019 +0200
    14.2 +++ b/test/src/engine_tests/KeyAttachmentTests.cc	Thu May 16 18:03:03 2019 +0200
    14.3 @@ -73,7 +73,7 @@
    14.4      message* enc_msg = NULL;
    14.5      message* dec_msg = NULL;
    14.6  
    14.7 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
    14.8 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
    14.9      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   14.10      TEST_ASSERT(enc_msg);
   14.11      stringlist_t* keylist = NULL;
   14.12 @@ -93,7 +93,7 @@
   14.13      message* enc_msg = NULL;
   14.14      message* dec_msg = NULL;
   14.15  
   14.16 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
   14.17 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
   14.18      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   14.19      TEST_ASSERT(enc_msg);
   14.20      stringlist_t* keylist = NULL;
   14.21 @@ -119,7 +119,7 @@
   14.22      message* enc_msg = NULL;
   14.23      message* dec_msg = NULL;
   14.24  
   14.25 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
   14.26 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
   14.27      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   14.28      TEST_ASSERT(enc_msg);
   14.29      stringlist_t* keylist = NULL;
   14.30 @@ -145,7 +145,7 @@
   14.31      message* enc_msg = NULL;
   14.32      message* dec_msg = NULL;
   14.33  
   14.34 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
   14.35 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
   14.36      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   14.37      TEST_ASSERT(enc_msg);
   14.38      stringlist_t* keylist = NULL;
   14.39 @@ -171,7 +171,7 @@
   14.40      message* enc_msg = NULL;
   14.41      message* dec_msg = NULL;
   14.42  
   14.43 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
   14.44 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
   14.45      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   14.46      TEST_ASSERT(enc_msg);
   14.47      stringlist_t* keylist = NULL;
   14.48 @@ -201,7 +201,7 @@
   14.49      message* enc_msg = NULL;
   14.50      message* dec_msg = NULL;
   14.51  
   14.52 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
   14.53 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
   14.54      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   14.55      TEST_ASSERT(enc_msg);
   14.56      stringlist_t* keylist = NULL;
   14.57 @@ -221,7 +221,7 @@
   14.58      message* enc_msg = NULL;
   14.59      message* dec_msg = NULL;
   14.60  
   14.61 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
   14.62 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
   14.63      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   14.64      TEST_ASSERT(enc_msg);
   14.65      stringlist_t* keylist = NULL;
   14.66 @@ -247,7 +247,7 @@
   14.67      message* enc_msg = NULL;
   14.68      message* dec_msg = NULL;
   14.69  
   14.70 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
   14.71 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
   14.72      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   14.73      TEST_ASSERT(enc_msg);
   14.74      stringlist_t* keylist = NULL;
   14.75 @@ -273,7 +273,7 @@
   14.76      message* enc_msg = NULL;
   14.77      message* dec_msg = NULL;
   14.78  
   14.79 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
   14.80 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
   14.81      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   14.82      TEST_ASSERT(enc_msg);
   14.83      stringlist_t* keylist = NULL;
   14.84 @@ -328,7 +328,7 @@
   14.85      message* enc_msg = NULL;
   14.86      message* dec_msg = NULL;
   14.87  
   14.88 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
   14.89 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
   14.90      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   14.91      TEST_ASSERT(enc_msg);
   14.92      stringlist_t* keylist = NULL;
   14.93 @@ -348,7 +348,7 @@
   14.94      message* enc_msg = NULL;
   14.95      message* dec_msg = NULL;
   14.96  
   14.97 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
   14.98 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
   14.99      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
  14.100      TEST_ASSERT(enc_msg);
  14.101      stringlist_t* keylist = NULL;
  14.102 @@ -373,7 +373,7 @@
  14.103      message* enc_msg = NULL;
  14.104      message* dec_msg = NULL;
  14.105  
  14.106 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
  14.107 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
  14.108      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
  14.109      TEST_ASSERT(enc_msg);
  14.110      stringlist_t* keylist = NULL;
  14.111 @@ -399,7 +399,7 @@
  14.112      message* enc_msg = NULL;
  14.113      message* dec_msg = NULL;
  14.114  
  14.115 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
  14.116 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
  14.117      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
  14.118      TEST_ASSERT(enc_msg);
  14.119      stringlist_t* keylist = NULL;
  14.120 @@ -424,7 +424,7 @@
  14.121      message* enc_msg = NULL;
  14.122      message* dec_msg = NULL;
  14.123  
  14.124 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
  14.125 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
  14.126      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
  14.127      TEST_ASSERT(enc_msg);
  14.128      stringlist_t* keylist = NULL;
  14.129 @@ -449,7 +449,7 @@
  14.130      message* enc_msg = NULL;
  14.131      message* dec_msg = NULL;
  14.132  
  14.133 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
  14.134 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
  14.135      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
  14.136      TEST_ASSERT(enc_msg);
  14.137      stringlist_t* keylist = NULL;
  14.138 @@ -469,7 +469,7 @@
  14.139      message* enc_msg = NULL;
  14.140      message* dec_msg = NULL;
  14.141  
  14.142 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
  14.143 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
  14.144      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
  14.145      TEST_ASSERT(enc_msg);
  14.146      stringlist_t* keylist = NULL;
  14.147 @@ -494,7 +494,7 @@
  14.148      message* enc_msg = NULL;
  14.149      message* dec_msg = NULL;
  14.150  
  14.151 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
  14.152 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
  14.153      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
  14.154      TEST_ASSERT(enc_msg);
  14.155      stringlist_t* keylist = NULL;
  14.156 @@ -519,7 +519,7 @@
  14.157      message* enc_msg = NULL;
  14.158      message* dec_msg = NULL;
  14.159  
  14.160 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg);
  14.161 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL);
  14.162      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
  14.163      TEST_ASSERT(enc_msg);
  14.164      stringlist_t* keylist = NULL;
    15.1 --- a/test/src/engine_tests/LeastColorGroupTests.cc	Thu May 16 17:54:28 2019 +0200
    15.2 +++ b/test/src/engine_tests/LeastColorGroupTests.cc	Thu May 16 18:03:03 2019 +0200
    15.3 @@ -69,7 +69,7 @@
    15.4      PEP_rating rating;
    15.5      PEP_decrypt_flags_t flags;
    15.6      
    15.7 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
    15.8 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
    15.9      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   15.10      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
   15.11      final_ptr = msg_ptr;
    16.1 --- a/test/src/engine_tests/LeastCommonDenomColorTests.cc	Thu May 16 17:54:28 2019 +0200
    16.2 +++ b/test/src/engine_tests/LeastCommonDenomColorTests.cc	Thu May 16 18:03:03 2019 +0200
    16.3 @@ -68,7 +68,7 @@
    16.4      PEP_rating rating;
    16.5      PEP_decrypt_flags_t flags;
    16.6      
    16.7 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
    16.8 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
    16.9      TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   16.10      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
   16.11  
   16.12 @@ -117,7 +117,7 @@
   16.13      keylist = nullptr;
   16.14      rating = PEP_rating_unreliable;
   16.15  
   16.16 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   16.17 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
   16.18      TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   16.19      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
   16.20      flags = 0;
    17.1 --- a/test/src/engine_tests/MessageApiTests.cc	Thu May 16 17:54:28 2019 +0200
    17.2 +++ b/test/src/engine_tests/MessageApiTests.cc	Thu May 16 18:03:03 2019 +0200
    17.3 @@ -81,7 +81,7 @@
    17.4      cout << text2 << "\n";
    17.5  
    17.6      message *msg3 = nullptr;
    17.7 -    PEP_STATUS status3 = mime_decode_message(text2, strlen(text2), &msg3);
    17.8 +    PEP_STATUS status3 = mime_decode_message(text2, strlen(text2), &msg3, NULL);
    17.9      TEST_ASSERT_MSG((status3 == PEP_STATUS_OK), "status3 == PEP_STATUS_OK");
   17.10      const string string3 = text2;
   17.11      //free(text2);
   17.12 @@ -133,7 +133,7 @@
   17.13      inFile3.close();
   17.14  
   17.15      message *msg5 = nullptr;
   17.16 -    PEP_STATUS status5 = mime_decode_message(text3.c_str(), text3.length(), &msg5);
   17.17 +    PEP_STATUS status5 = mime_decode_message(text3.c_str(), text3.length(), &msg5, NULL);
   17.18      TEST_ASSERT_MSG((status5 == PEP_STATUS_OK), "status5 == PEP_STATUS_OK");
   17.19  
   17.20      message *msg6 = nullptr;
    18.1 --- a/test/src/engine_tests/MessageTwoPointOhTests.cc	Thu May 16 17:54:28 2019 +0200
    18.2 +++ b/test/src/engine_tests/MessageTwoPointOhTests.cc	Thu May 16 18:03:03 2019 +0200
    18.3 @@ -121,7 +121,7 @@
    18.4  //    cout << decrypted_text << endl;
    18.5      
    18.6      message* decoded_msg = nullptr;
    18.7 -    status = mime_decode_message(encoded_text, strlen(encoded_text), &decoded_msg);
    18.8 +    status = mime_decode_message(encoded_text, strlen(encoded_text), &decoded_msg, NULL);
    18.9      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   18.10      const string string3 = encoded_text;
   18.11        
   18.12 @@ -155,7 +155,7 @@
   18.13      }
   18.14       
   18.15      decrypted_msg->enc_format = PEP_enc_none; 
   18.16 -    status = _mime_encode_message_internal(decrypted_msg, false, &encoded_text, false);
   18.17 +    status = _mime_encode_message_internal(decrypted_msg, false, &encoded_text, false, false);
   18.18      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   18.19      TEST_ASSERT_MSG((encoded_text), "encoded_text");
   18.20      cout << "Decrypted message: " << endl;
    19.1 --- a/test/src/engine_tests/MimeTests.cc	Thu May 16 17:54:28 2019 +0200
    19.2 +++ b/test/src/engine_tests/MimeTests.cc	Thu May 16 18:03:03 2019 +0200
    19.3 @@ -44,7 +44,7 @@
    19.4  
    19.5      cout << "decoding message…\n";
    19.6      message *msg3;
    19.7 -    PEP_STATUS status3 = mime_decode_message(mimetext3.c_str(), mimetext3.length(), &msg3);
    19.8 +    PEP_STATUS status3 = mime_decode_message(mimetext3.c_str(), mimetext3.length(), &msg3, NULL);
    19.9      assert(status3 == PEP_STATUS_OK);
   19.10      assert(msg3);
   19.11      cout << "decoded.\n\n";
    20.1 --- a/test/src/engine_tests/PepSubjectReceivedTests.cc	Thu May 16 17:54:28 2019 +0200
    20.2 +++ b/test/src/engine_tests/PepSubjectReceivedTests.cc	Thu May 16 18:03:03 2019 +0200
    20.3 @@ -61,7 +61,7 @@
    20.4      PEP_rating rating;
    20.5      PEP_decrypt_flags_t flags;
    20.6      
    20.7 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
    20.8 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
    20.9      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   20.10      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
   20.11      final_ptr = msg_ptr;
   20.12 @@ -95,7 +95,7 @@
   20.13      keylist = nullptr;
   20.14      rating = PEP_rating_unreliable;
   20.15      
   20.16 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   20.17 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
   20.18      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   20.19      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
   20.20      final_ptr = msg_ptr;
   20.21 @@ -129,7 +129,7 @@
   20.22      
   20.23      mailtext = slurp("test_mails/pEp_subject_normal_signed_2a.eml");
   20.24      
   20.25 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   20.26 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
   20.27      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   20.28      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
   20.29      final_ptr = msg_ptr;
   20.30 @@ -162,7 +162,7 @@
   20.31      
   20.32      mailtext = slurp("test_mails/p3p_subject_normal_signed_2b.eml");
   20.33      
   20.34 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   20.35 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
   20.36      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   20.37      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
   20.38      final_ptr = msg_ptr;
   20.39 @@ -196,7 +196,7 @@
   20.40      
   20.41      mailtext = slurp("test_mails/pEp_encrypted_subject_IS_pEp_3a.eml");
   20.42      
   20.43 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   20.44 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
   20.45      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   20.46      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
   20.47      final_ptr = msg_ptr;
   20.48 @@ -230,7 +230,7 @@
   20.49      
   20.50      mailtext = slurp("test_mails/p3p_encrypted_subject_IS_pEp_3b.eml");
   20.51      
   20.52 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   20.53 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
   20.54      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   20.55      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
   20.56      final_ptr = msg_ptr;
   20.57 @@ -265,7 +265,7 @@
   20.58      
   20.59      mailtext = slurp("test_mails/pEp_subject_pEp_replaced_w_pEp_4a.eml");
   20.60      
   20.61 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   20.62 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
   20.63      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   20.64      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
   20.65      final_ptr = msg_ptr;
   20.66 @@ -299,7 +299,7 @@
   20.67      
   20.68      mailtext = slurp("test_mails/pEp_subject_pEp_replaced_w_p3p_4b.eml");
   20.69      
   20.70 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   20.71 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
   20.72      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   20.73      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
   20.74      final_ptr = msg_ptr;
   20.75 @@ -333,7 +333,7 @@
   20.76      
   20.77      mailtext = slurp("test_mails/pEp_subject_p3p_replaced_w_pEp_4c.eml");
   20.78      
   20.79 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   20.80 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
   20.81      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   20.82      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
   20.83      final_ptr = msg_ptr;
   20.84 @@ -367,7 +367,7 @@
   20.85      
   20.86      mailtext = slurp("test_mails/pEp_subject_p3p_replaced_w_p3p_4d.eml");
   20.87      
   20.88 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   20.89 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
   20.90      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   20.91      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
   20.92      final_ptr = msg_ptr;
   20.93 @@ -402,7 +402,7 @@
   20.94      
   20.95      mailtext = slurp("test_mails/pEp_unencrypted_pEp_subject_5a.eml");
   20.96      
   20.97 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   20.98 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
   20.99      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
  20.100      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
  20.101      final_ptr = msg_ptr;
  20.102 @@ -437,7 +437,7 @@
  20.103      
  20.104      mailtext = slurp("test_mails/pEp_unencrypted_p3p_subject_5b.eml");
  20.105      
  20.106 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  20.107 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
  20.108      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
  20.109      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
  20.110      final_ptr = msg_ptr;
  20.111 @@ -471,7 +471,7 @@
  20.112      
  20.113      mailtext = slurp("test_mails/pEp_subject_normal_unencrypted_6.eml");
  20.114      
  20.115 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  20.116 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr, NULL);
  20.117      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
  20.118      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
  20.119      final_ptr = msg_ptr;
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/test/src/engine_tests/SenderFPRTests.cc	Thu May 16 18:03:03 2019 +0200
    21.3 @@ -0,0 +1,79 @@
    21.4 +// This file is under GNU General Public License 3.0
    21.5 +// see LICENSE.txt
    21.6 +
    21.7 +#include <stdlib.h>
    21.8 +#include <cstring>
    21.9 +#include <string>
   21.10 +
   21.11 +#include <cpptest.h>
   21.12 +#include "test_util.h"
   21.13 +
   21.14 +#include "pEpEngine.h"
   21.15 +#include "mime.h"
   21.16 +
   21.17 +#include "EngineTestIndividualSuite.h"
   21.18 +#include "SenderFPRTests.h"
   21.19 +
   21.20 +using namespace std;
   21.21 +
   21.22 +SenderFPRTests::SenderFPRTests(string suitename, string test_home_dir) :
   21.23 +    EngineTestIndividualSuite::EngineTestIndividualSuite(suitename, test_home_dir) {
   21.24 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("SenderFPRTests::check_sender_f_p_r"),
   21.25 +                                                                      static_cast<Func>(&SenderFPRTests::check_sender_f_p_r)));
   21.26 +}
   21.27 +
   21.28 +void SenderFPRTests::check_sender_f_p_r() {
   21.29 +    const char* alice_fpr = "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97";
   21.30 +    const char* bob_fpr = "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39";
   21.31 +    PEP_STATUS status = read_file_and_import_key(session,
   21.32 +                "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
   21.33 +    TEST_ASSERT(status == PEP_KEY_IMPORTED);
   21.34 +    status = set_up_ident_from_scratch(session,
   21.35 +                "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
   21.36 +                "pep.test.alice@pep-project.org", alice_fpr,
   21.37 +                PEP_OWN_USERID, "Alice in Wonderland", NULL, true
   21.38 +            );
   21.39 +    TEST_ASSERT(status == PEP_STATUS_OK);
   21.40 +    TEST_ASSERT_MSG(slurp_and_import_key(session, "test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc"),
   21.41 +                    "Unable to import test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc");
   21.42 +                    
   21.43 +
   21.44 +    message* msg = new_message(PEP_dir_outgoing);
   21.45 +    pEp_identity* alice = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, NULL);                
   21.46 +    pEp_identity* bob = new_identity("pep.test.bob@pep-project.org", NULL, "Bob", NULL);
   21.47 +    status = myself(session, alice);
   21.48 +    TEST_ASSERT(status == PEP_STATUS_OK);
   21.49 +    status = update_identity(session, bob);
   21.50 +    TEST_ASSERT(status == PEP_STATUS_OK);
   21.51 +    
   21.52 +    status = set_as_pEp_user(session, bob);
   21.53 +    TEST_ASSERT(status == PEP_STATUS_OK);
   21.54 +
   21.55 +    msg->to = new_identity_list(bob);
   21.56 +    msg->from = alice;
   21.57 +    msg->shortmsg = strdup("Yo Bob!");
   21.58 +    msg->longmsg = strdup("Look at my hot new sender fpr field!");
   21.59 +
   21.60 +    message* enc_msg = NULL;
   21.61 +    
   21.62 +    status = encrypt_message(session, msg, NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
   21.63 +    TEST_ASSERT(status == PEP_STATUS_OK);
   21.64 +    TEST_ASSERT(stringpair_list_find(enc_msg->opt_fields, "X-pEp-Sender-FPR") == NULL);
   21.65 +    
   21.66 +    message* dec_msg = NULL;
   21.67 +
   21.68 +    stringlist_t* keylist = NULL;
   21.69 +    PEP_rating rating;
   21.70 +    PEP_decrypt_flags_t flags = 0;
   21.71 +    status = decrypt_message(session, enc_msg, &dec_msg, &keylist, &rating, &flags);
   21.72 +    TEST_ASSERT(status == PEP_STATUS_OK);
   21.73 +
   21.74 +    char* text = NULL;
   21.75 +    mime_encode_message(dec_msg, false, &text);
   21.76 +    cout << text << endl;
   21.77 +    free(text);
   21.78 +    
   21.79 +    stringpair_list_t* fpr_node = stringpair_list_find(dec_msg->opt_fields, "X-pEp-Sender-FPR");
   21.80 +    TEST_ASSERT(fpr_node);
   21.81 +    TEST_ASSERT(strcmp(fpr_node->value->value, alice_fpr) == 0);
   21.82 +}
    22.1 --- a/test/src/engine_tests/SimpleBodyNotAltTests.cc	Thu May 16 17:54:28 2019 +0200
    22.2 +++ b/test/src/engine_tests/SimpleBodyNotAltTests.cc	Thu May 16 18:03:03 2019 +0200
    22.3 @@ -29,7 +29,7 @@
    22.4      string msg = slurp("test_mails/text message with html attach.eml");
    22.5      message* parsed = NULL;
    22.6  
    22.7 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &parsed);
    22.8 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &parsed, NULL);
    22.9      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   22.10      TEST_ASSERT(parsed);
   22.11      TEST_ASSERT(parsed->longmsg);
   22.12 @@ -47,7 +47,7 @@
   22.13      string msg = slurp("test_mails/HTML-only body w text attachment.eml");
   22.14      message* parsed = NULL;
   22.15  
   22.16 -    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &parsed);
   22.17 +    PEP_STATUS status = mime_decode_message(msg.c_str(), msg.size(), &parsed, NULL);
   22.18      TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   22.19      TEST_ASSERT(parsed);
   22.20      TEST_ASSERT(parsed->longmsg == NULL);
    23.1 --- a/test/src/util/test_util.cc	Thu May 16 17:54:28 2019 +0200
    23.2 +++ b/test/src/util/test_util.cc	Thu May 16 18:03:03 2019 +0200
    23.3 @@ -495,7 +495,7 @@
    23.4      message* dec_msg = NULL;
    23.5      *mime_plaintext = NULL;
    23.6  
    23.7 -    status = mime_decode_message(mimetext, size, &tmp_msg);
    23.8 +    status = mime_decode_message(mimetext, size, &tmp_msg, NULL);
    23.9      if (status != PEP_STATUS_OK)
   23.10          goto pEp_error;
   23.11  
   23.12 @@ -542,7 +542,7 @@
   23.13      }
   23.14  
   23.15      if (*flags & PEP_decrypt_flag_src_modified) {
   23.16 -        _mime_encode_message_internal(tmp_msg, false, modified_src, true);
   23.17 +        _mime_encode_message_internal(tmp_msg, false, modified_src, true, false);
   23.18          if (!modified_src) {
   23.19              *flags &= (~PEP_decrypt_flag_src_modified);
   23.20              decrypt_status = PEP_CANNOT_REENCRYPT; // Because we couldn't return it, I guess.
   23.21 @@ -550,7 +550,7 @@
   23.22      }
   23.23  
   23.24      // FIXME: test with att
   23.25 -    status = _mime_encode_message_internal(dec_msg, false, mime_plaintext, true);
   23.26 +    status = _mime_encode_message_internal(dec_msg, false, mime_plaintext, true, false);
   23.27  
   23.28      if (status == PEP_STATUS_OK)
   23.29      {
   23.30 @@ -580,7 +580,7 @@
   23.31      message* tmp_msg = NULL;
   23.32      message* enc_msg = NULL;
   23.33  
   23.34 -    status = mime_decode_message(mimetext, size, &tmp_msg);
   23.35 +    status = mime_decode_message(mimetext, size, &tmp_msg, NULL);
   23.36      if (status != PEP_STATUS_OK)
   23.37          goto pEp_error;
   23.38  
   23.39 @@ -635,7 +635,7 @@
   23.40          goto pEp_error;
   23.41      }
   23.42  
   23.43 -    status = _mime_encode_message_internal(enc_msg, false, mime_ciphertext, false);
   23.44 +    status = _mime_encode_message_internal(enc_msg, false, mime_ciphertext, false, false);
   23.45  
   23.46  pEp_error:
   23.47      free_message(tmp_msg);
   23.48 @@ -660,7 +660,7 @@
   23.49      message* tmp_msg = NULL;
   23.50      message* enc_msg = NULL;
   23.51  
   23.52 -    status = mime_decode_message(mimetext, size, &tmp_msg);
   23.53 +    status = mime_decode_message(mimetext, size, &tmp_msg, NULL);
   23.54      if (status != PEP_STATUS_OK)
   23.55          goto pEp_error;
   23.56