src/pEpEngine.c
branchsequoia_windows
changeset 3868 157c5339cbb6
parent 3843 cbdc7255c019
parent 3863 e10b2a4785a5
child 3888 99d255a8dc60
     1.1 --- a/src/pEpEngine.c	Wed Jun 19 15:47:03 2019 +0200
     1.2 +++ b/src/pEpEngine.c	Fri Jun 21 18:41:56 2019 +0200
     1.3 @@ -4271,9 +4271,33 @@
     1.4              identity->username))
     1.5          return PEP_ILLEGAL_VALUE;
     1.6  
     1.7 +    const char* saved_username = NULL;
     1.8 +    const char* at = NULL;
     1.9 +    size_t uname_len = strlen(identity->username);
    1.10 +    
    1.11 +    if (uname_len > 0)
    1.12 +        at = strstr(identity->username, "@"); 
    1.13 +    
    1.14 +    if (at) {
    1.15 +        saved_username = identity->username;
    1.16 +        identity->username = calloc(uname_len + 3, 1);
    1.17 +        if (!identity->username) {
    1.18 +            identity->username = saved_username;
    1.19 +            return PEP_OUT_OF_MEMORY;
    1.20 +        }
    1.21 +        identity->username[0] = '"';
    1.22 +        strlcpy((identity->username) + 1, saved_username, uname_len + 1);
    1.23 +        identity->username[uname_len + 1] = '"';        
    1.24 +    }
    1.25 +
    1.26      PEP_STATUS status =
    1.27          session->cryptotech[PEP_crypt_OpenPGP].generate_keypair(session,
    1.28                  identity);
    1.29 +                
    1.30 +    if (saved_username) {
    1.31 +        free(identity->username);
    1.32 +        identity->username = saved_username;
    1.33 +    }            
    1.34      if (status != PEP_STATUS_OK)
    1.35          return status;
    1.36