stowing changes - broken commit, FYI fdik_sync
authorKrista Bennett <krista@pep-project.org>
Tue, 21 Mar 2017 14:41:59 +0100
branchfdik_sync
changeset 168420643edc4c53
parent 1683 55b11374209d
child 1687 e376c005ff2d
stowing changes - broken commit, FYI
src/Makefile
src/message_api.c
src/mime.c
src/mime.h
     1.1 --- a/src/Makefile	Fri Mar 17 18:27:46 2017 +0100
     1.2 +++ b/src/Makefile	Tue Mar 21 14:41:59 2017 +0100
     1.3 @@ -42,7 +42,7 @@
     1.4      CFLAGS+= -DNDEBUG
     1.5  endif
     1.6  
     1.7 -OPENPGP?=GPG
     1.8 +OPENPGP?=NETPGP
     1.9  ifeq ("$(OPENPGP)","GPG")
    1.10      NO_SOURCE=pgp_netpgp.c
    1.11      GPGME_IN?=$(HOME)
     2.1 --- a/src/message_api.c	Fri Mar 17 18:27:46 2017 +0100
     2.2 +++ b/src/message_api.c	Tue Mar 21 14:41:59 2017 +0100
     2.3 @@ -1781,30 +1781,10 @@
     2.4      /* that should be fixed at a higher level   */
     2.5      char* slong = src->longmsg;
     2.6      char* sform = src->longmsg_formatted;
     2.7 -    bloblist_t* satt = src->attachments;
     2.8      
     2.9      if ((!slong || slong[0] == '\0')
    2.10           && (!sform || sform[0] == '\0')) {
    2.11 -        if (satt) {
    2.12 -            const char* inner_mime_type = satt->mime_type;
    2.13 -            if (strcasecmp(inner_mime_type, "text/plain") == 0) {
    2.14 -                free(slong); /* in case of "" */
    2.15 -                src->longmsg = strndup(satt->value, satt->size); // N.B.: longmsg might be shorter, if attachment contains NUL bytes which are not allowed in text/plain!
    2.16 -                
    2.17 -                bloblist_t* next_node = satt->next;
    2.18 -                if (next_node) {
    2.19 -                    inner_mime_type = next_node->mime_type;
    2.20 -                    if (strcasecmp(inner_mime_type, "text/html") == 0) {
    2.21 -                        free(sform);
    2.22 -                        src->longmsg_formatted = strndup(next_node->value, next_node->size);  // N.B.: longmsg might be shorter, if attachment contains NUL bytes which are not allowed in text/plain!
    2.23 -                    }
    2.24 -                }
    2.25 -            }
    2.26 -            else if (strcasecmp(inner_mime_type, "text/html") == 0) {
    2.27 -                free(sform);
    2.28 -                src->longmsg_formatted = strndup(satt->value, satt->size);  // N.B.: longmsg might be shorter, if attachment contains NUL bytes which are not allowed in text/plain!
    2.29 -            }
    2.30 -        }
    2.31 +        status = raise_body(src);
    2.32      }
    2.33  
    2.34      dsig_text = detached_sig->value;
    2.35 @@ -1816,11 +1796,7 @@
    2.36      char* stext = (use_longmsg_formatted ? src->longmsg_formatted : src->longmsg);
    2.37      size_t ssize = strlen(stext);
    2.38  
    2.39 -    // FIXME
    2.40 -    //const char* plaintext = (src->longmsg ? src->longmsg : src->longmsg_formatted); // OK?
    2.41 -    //status = _get_signed_text(plaintext, strlen(plaintext), &stext, &ssize);
    2.42 -    //FIXME: this is again about MIME. We need to make sure MIME/mail issues are sanitised out
    2.43 -    // before we get this far
    2.44 +    status = _get_signed_text(plaintext, strlen(plaintext), &stext, &ssize);
    2.45      stringlist_t *_verify_keylist = NULL;
    2.46  
    2.47      if (ssize > 0 && stext) {
    2.48 @@ -1932,30 +1908,10 @@
    2.49              
    2.50              char* slong = src->longmsg;
    2.51              char* sform = src->longmsg_formatted;
    2.52 -            bloblist_t* satt = src->attachments;
    2.53              
    2.54              if ((!slong || slong[0] == '\0')
    2.55                   && (!sform || sform[0] == '\0')) {
    2.56 -                if (satt) {
    2.57 -                    const char* inner_mime_type = satt->mime_type;
    2.58 -                    if (strcasecmp(inner_mime_type, "text/plain") == 0) {
    2.59 -                        free(slong); /* in case of "" */
    2.60 -                        src->longmsg = strndup(satt->value, satt->size); // N.B.: longmsg might be shorter, if attachment contains NUL bytes which are not allowed in text/plain!
    2.61 -                        
    2.62 -                        bloblist_t* next_node = satt->next;
    2.63 -                        if (next_node) {
    2.64 -                            inner_mime_type = next_node->mime_type;
    2.65 -                            if (strcasecmp(inner_mime_type, "text/html") == 0) {
    2.66 -                                free(sform);
    2.67 -                                src->longmsg_formatted = strndup(next_node->value, next_node->size);  // N.B.: longmsg might be shorter, if attachment contains NUL bytes which are not allowed in text/plain!
    2.68 -                            }
    2.69 -                        }
    2.70 -                    }
    2.71 -                    else if (strcasecmp(inner_mime_type, "text/html") == 0) {
    2.72 -                        free(sform);
    2.73 -                        src->longmsg_formatted = strndup(satt->value, satt->size);  // N.B.: longmsg might be shorter, if attachment contains NUL bytes which are not allowed in text/plain!
    2.74 -                    }
    2.75 -                }
    2.76 +                raise_body(src);
    2.77              }
    2.78              
    2.79              return PEP_UNENCRYPTED;
    2.80 @@ -2007,30 +1963,10 @@
    2.81                  
    2.82                  char* mlong = msg->longmsg;
    2.83                  char* mform = msg->longmsg_formatted;
    2.84 -                bloblist_t* matt = msg->attachments;
    2.85                  
    2.86                  if ((!mlong || mlong[0] == '\0')
    2.87                       && (!mform || mform[0] == '\0')) {
    2.88 -                    if (matt) {
    2.89 -                        const char* inner_mime_type = matt->mime_type;
    2.90 -                        if (strcasecmp(inner_mime_type, "text/plain") == 0) {
    2.91 -                            free(mlong); /* in case of "" */
    2.92 -                            msg->longmsg = strndup(matt->value, matt->size);
    2.93 -                            
    2.94 -                            bloblist_t* next_node = matt->next;
    2.95 -                            if (next_node) {
    2.96 -                                inner_mime_type = next_node->mime_type;
    2.97 -                                if (strcasecmp(inner_mime_type, "text/html") == 0) {
    2.98 -                                    free(mform);
    2.99 -                                    msg->longmsg_formatted = strndup(next_node->value, next_node->size);
   2.100 -                                }
   2.101 -                            }
   2.102 -                        }
   2.103 -                        else if (strcasecmp(inner_mime_type, "text/html") == 0) {
   2.104 -                            free(mform);
   2.105 -                            msg->longmsg_formatted = strndup(matt->value, matt->size);
   2.106 -                        }
   2.107 -                    }
   2.108 +                    status = raise_body(msg);
   2.109                      if (msg->shortmsg) {
   2.110                          free(src->shortmsg);
   2.111                          src->shortmsg = strdup(msg->shortmsg);
     3.1 --- a/src/mime.c	Fri Mar 17 18:27:46 2017 +0100
     3.2 +++ b/src/mime.c	Tue Mar 21 14:41:59 2017 +0100
     3.3 @@ -26,6 +26,36 @@
     3.4      }
     3.5  }
     3.6  
     3.7 +PEP_STATUS raise_body(message* msg) {
     3.8 +    char* mlong = msg->longmsg;
     3.9 +    char* mform = msg->longmsg_formatted;
    3.10 +    bloblist_t* matt = msg->attachments;
    3.11 +
    3.12 +    if (matt) {
    3.13 +        const char* inner_mime_type = matt->mime_type;
    3.14 +        if (strcasecmp(inner_mime_type, "text/plain") == 0) {
    3.15 +            free(mlong); /* in case of "" */
    3.16 +            msg->longmsg = strndup(matt->value, matt->size);
    3.17 +            
    3.18 +            bloblist_t* next_node = matt->next;
    3.19 +            if (next_node) {
    3.20 +                inner_mime_type = next_node->mime_type;
    3.21 +                if (strcasecmp(inner_mime_type, "text/html") == 0) {
    3.22 +                    free(mform);
    3.23 +                    msg->longmsg_formatted = strndup(next_node->value, next_node->size);
    3.24 +                }
    3.25 +            }
    3.26 +        }
    3.27 +        else if (strcasecmp(inner_mime_type, "text/html") == 0) {
    3.28 +            free(mform);
    3.29 +            msg->longmsg_formatted = strndup(matt->value, matt->size);
    3.30 +        }
    3.31 +    }
    3.32 +    // FIXME: question remains of whether or not we should remove the associated attachment
    3.33 +    return PEP_STATUS_OK; // FIXME: real error checking
    3.34 +}
    3.35 +
    3.36 +
    3.37  DYNAMIC_API bool is_PGP_message_text(const char *text)
    3.38  {
    3.39      if (text == NULL)
     4.1 --- a/src/mime.h	Fri Mar 17 18:27:46 2017 +0100
     4.2 +++ b/src/mime.h	Tue Mar 21 14:41:59 2017 +0100
     4.3 @@ -9,6 +9,9 @@
     4.4  extern "C" {
     4.5  #endif
     4.6  
     4.7 +// pEp-internal functions
     4.8 +PEP_STATUS raise_body(message* msg);
     4.9 +
    4.10  
    4.11  // is_PGP_message_text() - determine if text encodes a PGP message
    4.12  //
    4.13 @@ -78,4 +81,3 @@
    4.14  #ifdef __cplusplus
    4.15  }
    4.16  #endif
    4.17 -