ENGINE-9: *****!*!*!*!*!*! WARNING - THIS COMMIT BREAKS API COMPATIBILITY DUE TO THE ADDITION OF A CONTENT ID FIELD TO BLOBLISTS AND TO THEIR CONSTRUCTORS !*!*!*!*!***** --- Bloblists now have a content id argument, and test cases and internal uses of bloblists have been adjusted. ENGINE-9
authorKrista Bennett <krista@pep-project.org>
Wed, 07 Jun 2017 13:41:45 +0200
branchENGINE-9
changeset 1829909cb53fc069
parent 1828 a82418b6553b
child 1830 acb58598b45b
ENGINE-9: *****!*!*!*!*!*! WARNING - THIS COMMIT BREAKS API COMPATIBILITY DUE TO THE ADDITION OF A CONTENT ID FIELD TO BLOBLISTS AND TO THEIR CONSTRUCTORS !*!*!*!*!***** --- Bloblists now have a content id argument, and test cases and internal uses of bloblists have been adjusted.
src/baseprotocol.c
src/bloblist.c
src/etpan_mime.c
src/message_api.c
src/mime.c
test/bloblist_test.cc
test/decorate_test.cc
test/external_revoke_test.cc
     1.1 --- a/src/baseprotocol.c	Tue Jun 06 18:00:40 2017 +0200
     1.2 +++ b/src/baseprotocol.c	Wed Jun 07 13:41:45 2017 +0200
     1.3 @@ -18,7 +18,7 @@
     1.4          return PEP_ILLEGAL_VALUE;
     1.5  
     1.6      bloblist_t *bl = bloblist_add(msg->attachments, payload, size,
     1.7 -            "application/pEp.sync", "ignore_this_attachment.pEp");
     1.8 +            "application/pEp.sync", "ignore_this_attachment.pEp", NULL);
     1.9      if (bl == NULL)
    1.10          goto enomem;
    1.11  
    1.12 @@ -84,4 +84,3 @@
    1.13      free_message(msg);
    1.14      return PEP_OUT_OF_MEMORY;
    1.15  }
    1.16 -
     2.1 --- a/src/bloblist.c	Tue Jun 06 18:00:40 2017 +0200
     2.2 +++ b/src/bloblist.c	Wed Jun 07 13:41:45 2017 +0200
     2.3 @@ -150,7 +150,7 @@
     2.4          if (content_id) {
     2.5              bloblist->content_id = strdup(content_id);
     2.6              if (bloblist->content_id == NULL) {
     2.7 -                free(bloblist->content_id)
     2.8 +                free(bloblist->content_id);
     2.9                  free(bloblist->mime_type);
    2.10                  free(bloblist);
    2.11                  return NULL;
     3.1 --- a/src/etpan_mime.c	Tue Jun 06 18:00:40 2017 +0200
     3.2 +++ b/src/etpan_mime.c	Wed Jun 07 13:41:45 2017 +0200
     3.3 @@ -630,6 +630,29 @@
     3.4      return NULL;
     3.5  }
     3.6  
     3.7 +// FIXME: We should combine this with _get_filename, IMHO
     3.8 +char * _get_content_id(struct mailmime *mime) {
     3.9 +    clist * _fieldlist = NULL;
    3.10 +
    3.11 +    assert(mime);
    3.12 +
    3.13 +    if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list)
    3.14 +        _fieldlist = mime->mm_mime_fields->fld_list;
    3.15 +    else
    3.16 +        return NULL;
    3.17 +
    3.18 +    clistiter *cur;
    3.19 +    for (cur = clist_begin(_fieldlist); cur; cur = clist_next(cur)) {
    3.20 +        struct mailmime_field * _field = clist_content(cur);
    3.21 +        if (_field && _field->fld_type == MAILMIME_FIELD_ID) {
    3.22 +            return _field->fld_data.fld_id; // returns NULL if it's not there, so...
    3.23 +        }
    3.24 +    }
    3.25 +
    3.26 +    return NULL;
    3.27 +}
    3.28 +
    3.29 +
    3.30  static bool parameter_has_value(
    3.31          struct mailmime_content *content,       
    3.32          const char *name,
    3.33 @@ -784,4 +807,3 @@
    3.34  
    3.35      return EINVAL;
    3.36  }
    3.37 -
     4.1 --- a/src/message_api.c	Tue Jun 06 18:00:40 2017 +0200
     4.2 +++ b/src/message_api.c	Wed Jun 07 13:41:45 2017 +0200
     4.3 @@ -1820,7 +1820,7 @@
     4.4                  bloblist_t *_s;
     4.5                  for (_s = src->attachments; _s; _s = _s->next) {
     4.6                      if (_s->value == NULL && _s->size == 0){
     4.7 -                        _m = bloblist_add(_m, NULL, 0, _s->mime_type, _s->filename
     4.8 +                        _m = bloblist_add(_m, NULL, 0, _s->mime_type, _s->filename,
     4.9                                            _s->content_id);
    4.10                          if (_m == NULL)
    4.11                              goto enomem;
     5.1 --- a/src/mime.c	Tue Jun 06 18:00:40 2017 +0200
     5.2 +++ b/src/mime.c	Wed Jun 07 13:41:45 2017 +0200
     5.3 @@ -1323,6 +1323,7 @@
     5.4                  char * mime_type;
     5.5                  char * charset;
     5.6                  char * filename;
     5.7 +                char * content_id;
     5.8                  int r;
     5.9  
    5.10                  r = _get_content_type(content, &mime_type, &charset);
    5.11 @@ -1344,6 +1345,7 @@
    5.12                      return status;
    5.13  
    5.14                  filename = _get_filename(mime);
    5.15 +                
    5.16                  char *_filename = NULL;
    5.17                  if (filename) {
    5.18                      size_t index = 0;
    5.19 @@ -1353,8 +1355,18 @@
    5.20                          goto enomem;
    5.21                  }
    5.22  
    5.23 +                content_id = _get_content_id(mime);
    5.24 +                char *_content_id = NULL;
    5.25 +                if (content_id) {
    5.26 +                    size_t index = 0;
    5.27 +                    r = mailmime_encoded_phrase_parse("utf-8", content_id,
    5.28 +                            strlen(filename), &index, "utf-8", &_content_id);
    5.29 +                    if (r)
    5.30 +                        goto enomem;                    
    5.31 +                }
    5.32 +                
    5.33                  bloblist_t *_a = bloblist_add(msg->attachments, data, size,
    5.34 -                        mime_type, _filename);
    5.35 +                        mime_type, _filename, _content_id);
    5.36                  free(_filename);
    5.37                  if (_a == NULL)
    5.38                      return PEP_OUT_OF_MEMORY;
     6.1 --- a/test/bloblist_test.cc	Tue Jun 06 18:00:40 2017 +0200
     6.2 +++ b/test/bloblist_test.cc	Wed Jun 07 13:41:45 2017 +0200
     6.3 @@ -112,7 +112,7 @@
     6.4          assert(p->value != dup_p->value);
     6.5          assert(p->mime_type != dup_p->mime_type || !(p->mime_type || dup_p->mime_type));
     6.6          assert(p->filename != dup_p->filename || !(p->filename || dup_p->filename));
     6.7 -        assert(p->content_id != bl_arr[i]->content_id || !(p->content_id || bl_arr[i]->content_id));
     6.8 +        assert(p->content_id != dup_p->content_id || !(p->content_id || dup_p->content_id));
     6.9  
    6.10          dup_p = dup_p->next;
    6.11          p = p->next;
    6.12 @@ -134,4 +134,3 @@
    6.13      
    6.14      return 0;
    6.15  }
    6.16 -
     7.1 --- a/test/decorate_test.cc	Tue Jun 06 18:00:40 2017 +0200
     7.2 +++ b/test/decorate_test.cc	Wed Jun 07 13:41:45 2017 +0200
     7.3 @@ -36,7 +36,7 @@
     7.4      outgoing_message->from = alice;
     7.5      outgoing_message->to = to_list;
     7.6      outgoing_message->shortmsg = strdup("Greetings, humans!");
     7.7 -    outgoing_message->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
     7.8 +    outgoing_message->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL, NULL);
     7.9      outgoing_message->longmsg = strdup("This is a dumb message.\nBut it's done.\n");
    7.10      assert(outgoing_message->longmsg);
    7.11      cout << "message created.\n";
     8.1 --- a/test/external_revoke_test.cc	Tue Jun 06 18:00:40 2017 +0200
     8.2 +++ b/test/external_revoke_test.cc	Wed Jun 07 13:41:45 2017 +0200
     8.3 @@ -91,7 +91,7 @@
     8.4      outgoing_msg->to = to_list;
     8.5      outgoing_msg->shortmsg = strdup("Greetings, humans!");
     8.6      outgoing_msg->longmsg = strdup("This is a test of the emergency message system. This is only a test. BEEP.");
     8.7 -    outgoing_msg->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
     8.8 +    outgoing_msg->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL, NULL);
     8.9      cout << "Message created.\n";
    8.10  
    8.11      message* encrypted_outgoing_msg = NULL;
    8.12 @@ -167,7 +167,7 @@
    8.13      outgoing_msg->to = to_list;
    8.14      outgoing_msg->shortmsg = strdup("Greetings, humans!");
    8.15      outgoing_msg->longmsg = strdup("This is a test of the emergency message system. This is only a test. BEEP.");
    8.16 -    outgoing_msg->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
    8.17 +    outgoing_msg->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL, NULL);
    8.18      cout << "message created.\n";
    8.19  
    8.20      encrypted_outgoing_msg = NULL;
    8.21 @@ -254,7 +254,7 @@
    8.22      outgoing_msg->to = to_list;
    8.23      outgoing_msg->shortmsg = strdup("Greetings, humans!");
    8.24      outgoing_msg->longmsg = strdup("This is a test of the emergency message system. This is only a test. BEEP.");
    8.25 -    outgoing_msg->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
    8.26 +    outgoing_msg->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL, NULL);
    8.27      cout << "Message created.\n";
    8.28  
    8.29      status = encrypt_message(session, outgoing_msg, NULL, &encrypted_outgoing_msg, PEP_enc_PGP_MIME, 0);