ENGINE-207: expanded boundary-parsing code for AppleMail encrypted w/ detached sigs to see if I can get Outlook and everything else to agree on things ENGINE-207
authorKrista Bennett <krista@pep-project.org>
Mon, 08 May 2017 15:18:42 +0200
branchENGINE-207
changeset 17551de149b237ab
parent 1750 33b2fa2368e6
child 1756 f46ce946ede9
ENGINE-207: expanded boundary-parsing code for AppleMail encrypted w/ detached sigs to see if I can get Outlook and everything else to agree on things
src/message_api.c
     1.1 --- a/src/message_api.c	Thu May 04 16:57:23 2017 +0200
     1.2 +++ b/src/message_api.c	Mon May 08 15:18:42 2017 +0200
     1.3 @@ -1458,8 +1458,8 @@
     1.4  
     1.5      char* curr_line = signpost;
     1.6  //    const char* end_text = ptext + psize;
     1.7 -    const char* boundary_key = "boundary=\"";
     1.8 -    const size_t BOUNDARY_KEY_SIZE = 10;
     1.9 +    const char* boundary_key = "boundary=";
    1.10 +    const size_t BOUNDARY_KEY_SIZE = 9;
    1.11  
    1.12      char* start_boundary = strstr(curr_line, boundary_key);
    1.13      if (!start_boundary)
    1.14 @@ -1467,11 +1467,17 @@
    1.15  
    1.16      start_boundary += BOUNDARY_KEY_SIZE;
    1.17  
    1.18 -    char* end_boundary = strstr(start_boundary, "\"");
    1.19 +    bool quoted = (*start_boundary == '"');
    1.20 +
    1.21 +    if (quoted)
    1.22 +        start_boundary++;
    1.23 +        
    1.24 +    char* end_boundary = (quoted ? strstr(start_boundary, "\"") : strstr(start_boundary, ";")); // FIXME: third possiblity is CRLF, or?
    1.25  
    1.26      if (!end_boundary)
    1.27          return PEP_UNKNOWN_ERROR;
    1.28  
    1.29 +    // Add space for the "--"
    1.30      size_t boundary_strlen = (end_boundary - start_boundary) + 2;
    1.31  
    1.32      signed_boundary = calloc(1, boundary_strlen + 1);
    1.33 @@ -1485,6 +1491,7 @@
    1.34  
    1.35      start_boundary += boundary_strlen;
    1.36  
    1.37 +    // we have an issue with \r I'll bet here..
    1.38      while (*start_boundary == '\n')
    1.39          start_boundary++;
    1.40