summaryrefslogtreecommitdiff
path: root/imap
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2014-06-20 23:23:19 -0600
committerEduardo Chappa <chappa@washington.edu>2014-06-20 23:23:19 -0600
commit121a42f3d82c1b98c384857960d14b2057a95c41 (patch)
tree3dbd271cc59b33cee35acd5a3dd55a997c7848bc /imap
parent60b67de2ba4be4d2bfeeeea685869e9a5a7363c0 (diff)
downloadalpine-121a42f3d82c1b98c384857960d14b2057a95c41.tar.xz
* new version 2.19.9992
* Alpine would not parse options from the command line, such as -patterns-filters2, correctly. * Add /usr/local/include as a path to find include and libs files for openssl in FreeBSD. * Management certificate screen now prints, in addition to the e-mail address of the owner of the certificates, the dates of validity and the MD5 hash of such certificates. * crash when processing message/rfc822 attachments that are encoded in base64. * Openssl: if /usr/local/ssl exists, assume that this is the intended place where ssl libraries, include files and certificates are located. Typically, distributions do not use this directory, so its existence indicates that Openssl has been specially installed there, so it is probably a preferred place to get the system Openssl files. * Postponed messages whose content-type is text/html, text/enriched and text/richtext are sent with that content-type, even though, after resuming composition, Alpine had changed its type to text/plain. * HTML: <BR>, <BR />, and <BR/&> are considered the same inline tag; the same is valid for the <HR> tag.
Diffstat (limited to 'imap')
-rw-r--r--imap/src/c-client/rfc822.c94
1 files changed, 74 insertions, 20 deletions
diff --git a/imap/src/c-client/rfc822.c b/imap/src/c-client/rfc822.c
index 03e92ca3..93663e65 100644
--- a/imap/src/c-client/rfc822.c
+++ b/imap/src/c-client/rfc822.c
@@ -1,4 +1,5 @@
/* ========================================================================
+ * Copyright 2013-2014 Eduardo Chappa
* Copyright 2008-2010 Mark Crispin
* ========================================================================
*/
@@ -36,6 +37,10 @@
#include "c-client.h"
+/* internal prototype */
+void initialize_body(BODY *b, char *h, char *t);
+
+
/* Support for deprecated features in earlier specifications. Note that this
* module follows RFC 2822, and all use of "rfc822" in function names is
* for compatibility. Only the code identified by the conditionals below
@@ -259,6 +264,23 @@ void rfc822_parse_msg_full (ENVELOPE **en,BODY **bdy,char *s,unsigned long i,
/* now parse the body */
if (body) rfc822_parse_content (body,bs,host,depth,flags);
}
+
+void
+initialize_body(BODY *b, char *h, char *t)
+{
+ if(b->type==TYPEMULTIPART){
+ PART *p;
+ cpytxt(&b->mime.text, h+b->mime.offset, b->mime.text.size);
+ cpytxt(&b->contents.text, t + b->contents.offset, b->size.bytes);
+
+ for(p=b->nested.part; p; p=p->next)
+ initialize_body((BODY *)p, h, t);
+ }
+ else {
+ cpytxt(&b->mime.text, h+b->mime.offset, b->mime.text.size);
+ cpytxt(&b->contents.text, t + b->contents.offset, b->size.bytes);
+ }
+}
/* Parse a message body content
* Accepts: pointer to body structure
@@ -337,33 +359,65 @@ void rfc822_parse_content (BODY *body,STRING *bs,char *h,unsigned long depth,
case ENC7BIT: /* these are valid nested encodings */
case ENC8BIT:
case ENCBINARY:
+ case ENCBASE64: /* message/rfc822 message encoded as base64 */
break;
default:
MM_LOG ("Ignoring nested encoding of message contents",PARSE);
}
- /* hunt for blank line */
+
for (c = '\012',j = 0; (i > j) && ((c != '\012') || (CHR(bs) != '\012'));
j++) if ((c1 = SNX (bs)) != '\015') c = c1;
- if (i > j) { /* unless no more text */
- c1 = SNX (bs); /* body starts here */
- j++; /* advance count */
+
+ switch(body->encoding){
+ case ENCBASE64:
+ SETPOS (bs,body->contents.offset);
+ s = (char *) fs_get ((size_t) j + 1);
+ for (s1 = s,k = j; k--; *s1++ = SNX (bs));
+ s[j] = '\0'; /* decode encoded text */
+ if((s1 = strstr(s, "--")) != NULL)
+ *(s1-2) = '\0';
+ s1 = (char *) rfc822_base64 (s, strlen(s), &k);
+ if(s1){
+ char *t = strstr(s1, "\r\n\r\n");
+
+ if(t != NULL){
+ char *u;
+ STRING b;
+
+ t += 4;
+ u = cpystr(t);
+ INIT(&b, mail_string, t, strlen(t));
+ rfc822_parse_msg_full(&body->nested.msg->env, &body->nested.msg->body, t,
+ strlen(t), &b, BADHOST, 0, 0);
+ initialize_body(body->nested.msg->body, u, u);
+ }
+ fs_give((void **)&s1);
+ }
+ fs_give((void **)&s);
+ break;
+
+ default:
+ if (i > j) { /* unless no more text */
+ c1 = SNX (bs); /* body starts here */
+ j++; /* advance count */
+ }
+ /* note body text offset and header size */
+ body->nested.msg->header.text.size = j;
+ body->nested.msg->text.text.size = body->contents.text.size - j;
+ body->nested.msg->text.offset = GETPOS (bs);
+ body->nested.msg->full.offset = body->nested.msg->header.offset =
+ body->contents.offset;
+ body->nested.msg->full.text.size = body->contents.text.size;
+ /* copy header string */
+ SETPOS (bs,body->contents.offset);
+ s = (char *) fs_get ((size_t) j + 1);
+ for (s1 = s,k = j; k--; *s1++ = SNX (bs));
+ s[j] = '\0'; /* tie off string (not really necessary) */
+ /* now parse the body */
+ rfc822_parse_msg_full (&body->nested.msg->env,&body->nested.msg->body,s,
+ j,bs,h,depth+1,flags);
+ fs_give ((void **) &s); /* free header string */
}
- /* note body text offset and header size */
- body->nested.msg->header.text.size = j;
- body->nested.msg->text.text.size = body->contents.text.size - j;
- body->nested.msg->text.offset = GETPOS (bs);
- body->nested.msg->full.offset = body->nested.msg->header.offset =
- body->contents.offset;
- body->nested.msg->full.text.size = body->contents.text.size;
- /* copy header string */
- SETPOS (bs,body->contents.offset);
- s = (char *) fs_get ((size_t) j + 1);
- for (s1 = s,k = j; k--; *s1++ = SNX (bs));
- s[j] = '\0'; /* tie off string (not really necessary) */
- /* now parse the body */
- rfc822_parse_msg_full (&body->nested.msg->env,&body->nested.msg->body,s,
- j,bs,h,depth+1,flags);
- fs_give ((void **) &s); /* free header string */
/* restore position */
SETPOS (bs,body->contents.offset);
}