Support for 0b attachment
authorEdouard Tisserant
Tue, 21 Jun 2016 15:33:06 +0200
changeset 747d357dceebec6
parent 746 753b1ec63285
child 749 a0de4bfddfcc
Support for 0b attachment
src/etpan_mime.c
src/message_api.c
src/mime.c
test/message_api_test.cc
     1.1 --- a/src/etpan_mime.c	Mon Jun 20 13:10:01 2016 +0200
     1.2 +++ b/src/etpan_mime.c	Tue Jun 21 15:33:06 2016 +0200
     1.3 @@ -315,9 +315,12 @@
     1.4      content = NULL;
     1.5      mime_fields = NULL;
     1.6  
     1.7 -    r = mailmime_set_body_text(mime, data, length);
     1.8 -    if (r != 0)
     1.9 -        goto enomem;
    1.10 +    if(length > 0)
    1.11 +    {
    1.12 +        r = mailmime_set_body_text(mime, data, length);
    1.13 +        if (r != 0)
    1.14 +            goto enomem;
    1.15 +    }
    1.16  
    1.17      return mime;
    1.18  
     2.1 --- a/src/message_api.c	Mon Jun 20 13:10:01 2016 +0200
     2.2 +++ b/src/message_api.c	Tue Jun 21 15:33:06 2016 +0200
     2.3 @@ -895,10 +895,9 @@
     2.4      bool remove = false;
     2.5  
     2.6      bloblist_t *bl;
     2.7 -    for (bl = msg->attachments; bl && bl->value; bl = bl->next) {
     2.8 -        assert(bl && bl->value && bl->size);
     2.9 -
    2.10 -        if (is_key(bl)) 
    2.11 +    for (bl = msg->attachments; bl && bl->value; bl = bl->next) 
    2.12 +    {
    2.13 +        if (bl && bl->value && bl->size && is_key(bl)) 
    2.14          {
    2.15              import_key(session, bl->value, bl->size, private_idents);
    2.16              remove = true;
     3.1 --- a/src/mime.c	Mon Jun 20 13:10:01 2016 +0200
     3.2 +++ b/src/mime.c	Tue Jun 21 15:33:06 2016 +0200
     3.3 @@ -693,8 +693,8 @@
     3.4  
     3.5          bloblist_t *_a;
     3.6          for (_a = msg->attachments; _a != NULL; _a = _a->next) {
     3.7 -            assert(_a->value);
     3.8 -            assert(_a->size);
     3.9 +            //assert(_a->value);
    3.10 +            //assert(_a->size);
    3.11  
    3.12              status = mime_attachment(_a, &submime);
    3.13              if (status != PEP_STATUS_OK)
     4.1 --- a/test/message_api_test.cc	Mon Jun 20 13:10:01 2016 +0200
     4.2 +++ b/test/message_api_test.cc	Tue Jun 21 15:33:06 2016 +0200
     4.3 @@ -33,6 +33,7 @@
     4.4      msg2->from = me2;
     4.5      msg2->to = to2;
     4.6      msg2->shortmsg = strdup("hello, world");
     4.7 +    msg2->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
     4.8      cout << "message created.\n";
     4.9  
    4.10      char *text2;