bugfix
authorVolker Birk <vb@pep-project.org>
Tue, 26 May 2015 19:50:13 +0200
changeset 2852b2db7f21020
parent 284 b0c524184969
child 287 63869b886f35
child 289 c0462b3893e5
bugfix
src/message_api.c
     1.1 --- a/src/message_api.c	Tue May 26 15:47:33 2015 +0200
     1.2 +++ b/src/message_api.c	Tue May 26 19:50:13 2015 +0200
     1.3 @@ -101,7 +101,7 @@
     1.4  
     1.5      bl = bloblist_add(msg->attachments, keydata, size, "application/pgp-keys",
     1.6              "pEp_key.asc");
     1.7 -    if (bl)
     1.8 +    if (msg->attachments == NULL && bl)
     1.9          msg->attachments = bl;
    1.10  }
    1.11  
    1.12 @@ -497,9 +497,6 @@
    1.13                  goto enomem;
    1.14              if (dst->attachments == NULL)
    1.15                  dst->attachments = _a;
    1.16 -
    1.17 -            add_opt_field(dst, "X-Content-PGP-Universal-Saved-Content-Type",
    1.18 -                    "text/html; charset=US-ASCII");
    1.19          }
    1.20          else {
    1.21              goto pep_error;
    1.22 @@ -522,10 +519,27 @@
    1.23              status = encrypt_and_sign(session, keys, ptext, psize, &ctext,
    1.24                      &csize);
    1.25              if (ctext) {
    1.26 -                char *filename = calloc(1, 20);
    1.27 -                ++n;
    1.28 -                n &= 0xffff;
    1.29 -                snprintf(filename, 20, "Attachment%d.pgp", n);
    1.30 +                char *filename = NULL;
    1.31 +
    1.32 +                if (_s->filename) {
    1.33 +                    size_t len = strlen(_s->filename);
    1.34 +                    filename = calloc(1, len + 5);
    1.35 +                    if (filename == NULL)
    1.36 +                        goto enomem;
    1.37 +
    1.38 +                    strcpy(filename, _s->filename);
    1.39 +                    strcpy(filename + len, ".pgp");
    1.40 +                }
    1.41 +                else {
    1.42 +                    filename = calloc(1, 20);
    1.43 +                    if (filename == NULL)
    1.44 +                        goto enomem;
    1.45 +
    1.46 +                    ++n;
    1.47 +                    n &= 0xffff;
    1.48 +                    snprintf(filename, 20, "Attachment%d.pgp", n);
    1.49 +                }
    1.50 +
    1.51                  _d = bloblist_add(_d, ctext, csize, "application/octet-stream",
    1.52                          filename);
    1.53                  if (_d == NULL)