PGP/MIME encoding will go wrong otherwise
authorVolker Birk <vb@pep.foundation>
Sat, 23 Dec 2017 18:41:02 +0100
changeset 2330783d3b1eaa21
parent 2322 5febb3fac06c
child 2331 71c86f7d4c77
PGP/MIME encoding will go wrong otherwise
src/message_api.c
     1.1 --- a/src/message_api.c	Mon Dec 18 16:02:29 2017 +0100
     1.2 +++ b/src/message_api.c	Sat Dec 23 18:41:02 2017 +0100
     1.3 @@ -63,17 +63,18 @@
     1.4  
     1.5  
     1.6  static stringpair_t* search_optfields(const message* msg, const char* key) {
     1.7 -    stringpair_list_t* opt_fields = msg->opt_fields;
     1.8 -    
     1.9 -    const stringpair_list_t* curr;
    1.10 -    
    1.11 -    for (curr = opt_fields; curr && curr->value; curr = curr->next) {
    1.12 -        if (curr->value->key) {
    1.13 -            if (strcasecmp(curr->value->key, key) == 0)
    1.14 -                return curr->value;
    1.15 -        }
    1.16 -    } 
    1.17 -    
    1.18 +    if (msg && key) {
    1.19 +        stringpair_list_t* opt_fields = msg->opt_fields;
    1.20 +        
    1.21 +        const stringpair_list_t* curr;
    1.22 +        
    1.23 +        for (curr = opt_fields; curr && curr->value; curr = curr->next) {
    1.24 +            if (curr->value->key) {
    1.25 +                if (strcasecmp(curr->value->key, key) == 0)
    1.26 +                    return curr->value;
    1.27 +            }
    1.28 +        } 
    1.29 +    }
    1.30      return NULL;
    1.31  }
    1.32  
    1.33 @@ -3191,9 +3192,6 @@
    1.34          GOTO(pep_error);
    1.35      }
    1.36  
    1.37 -    // Clear the encryption status, or mime_encode will ignore
    1.38 -    // the plaintext and do all sorts of other stupid things
    1.39 -    enc_msg->enc_format = PEP_enc_none;
    1.40      status = _mime_encode_message_internal(enc_msg, false, mime_ciphertext, false);
    1.41  
    1.42  pep_error: