ENGINE-314: solved overencoding problem for pgp attachments; mechanism is in place to add any known ascii (by definition) mime-type, so should this appear again, we know where to fix it. ENGINE_314
authorKrista Bennett <krista@pep-project.org>
Sat, 16 Dec 2017 20:42:03 +0100
branchENGINE_314
changeset 2320e5c008a12298
parent 2296 1a12f577ac71
child 2321 b71b768466e6
child 2715 f2f34c5f64b1
ENGINE-314: solved overencoding problem for pgp attachments; mechanism is in place to add any known ascii (by definition) mime-type, so should this appear again, we know where to fix it.
src/message_api.c
src/mime.c
     1.1 --- a/src/message_api.c	Wed Dec 06 18:26:13 2017 +0100
     1.2 +++ b/src/message_api.c	Sat Dec 16 20:42:03 2017 +0100
     1.3 @@ -3194,7 +3194,7 @@
     1.4      // Clear the encryption status, or mime_encode will ignore
     1.5      // the plaintext and do all sorts of other stupid things
     1.6      enc_msg->enc_format = PEP_enc_none;
     1.7 -    status = mime_encode_message(enc_msg, false, mime_ciphertext);
     1.8 +    status = _mime_encode_message_internal(enc_msg, false, mime_ciphertext, false);
     1.9  
    1.10  pep_error:
    1.11      free_message(tmp_msg);
     2.1 --- a/src/mime.c	Wed Dec 06 18:26:13 2017 +0100
     2.2 +++ b/src/mime.c	Sat Dec 16 20:42:03 2017 +0100
     2.3 @@ -97,6 +97,20 @@
     2.4      return status;
     2.5  }
     2.6  
     2.7 +static bool known_ascii_type(const char* mime_type) {
     2.8 +    const char* text_types[] = {"application/pgp-keys",
     2.9 +                                "application/pgp-encrypted"};
    2.10 +    const int TEXT_TYPE_ARRAY_SIZE = 3;
    2.11 +    
    2.12 +    int i;
    2.13 +    
    2.14 +    for (i = 0; i < TEXT_TYPE_ARRAY_SIZE; i++) {
    2.15 +        if (strcmp(text_types[i], mime_type) == 0)
    2.16 +            return true;
    2.17 +    }
    2.18 +    return false;
    2.19 +}
    2.20 +
    2.21  
    2.22  static PEP_STATUS mime_attachment(
    2.23          bloblist_t *blob,
    2.24 @@ -122,7 +136,9 @@
    2.25          mime_type = blob->mime_type;
    2.26  
    2.27      pEp_rid_list_t* resource = parse_uri(blob->filename);
    2.28 -    mime = get_file_part(resource, mime_type, blob->value, blob->size, transport_encode);
    2.29 +    bool already_ascii = known_ascii_type(mime_type);
    2.30 +    mime = get_file_part(resource, mime_type, blob->value, blob->size, 
    2.31 +                         (already_ascii ? false : transport_encode));
    2.32      free_rid_list(resource);
    2.33      
    2.34      assert(mime);