From: Art Cancro Date: Wed, 20 Jan 1999 20:06:31 +0000 (+0000) Subject: Added the ability to supply both start and end pointers to mime_parser() X-Git-Tag: v7.86~7936 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=db85e0f949a870c18298a830ac9ecc148d9aca10;p=citadel.git Added the ability to supply both start and end pointers to mime_parser() in order to facilitate recursive handling of multipart content. --- diff --git a/citadel/mime_parser.c b/citadel/mime_parser.c index a882bc4eb..4ea320812 100644 --- a/citadel/mime_parser.c +++ b/citadel/mime_parser.c @@ -77,8 +77,10 @@ char *memreadline(char *start, char *buf, int maxlen) { /* * Break out the components of a multipart message * (This function expects to be fed HEADERS + CONTENT) + * Note: NULL can be supplied as content_end; in this case, the message is + * considered to have ended when the parser encounters a 0x00 byte. */ -void mime_parser(char *content, +void mime_parser(char *content_start, char *content_end, void (*CallBack) (char *cbname, char *cbfilename, @@ -98,7 +100,7 @@ void mime_parser(char *content, int content_length; int i; - ptr = content; + ptr = content_start; bzero(boundary, sizeof boundary); bzero(content_type, sizeof content_type); bzero(encoding, sizeof encoding); @@ -108,6 +110,10 @@ void mime_parser(char *content, strcpy(header, ""); do { ptr = memreadline(ptr, buf, sizeof buf); + if (*ptr == 0) return; /* premature end of message */ + if (content_end != NULL) + if (ptr >= content_end) return; + for (i=0; i\n", boundary); - if (*ptr == 0) return; /* premature end of message */ /* If this is a multipart message, then recursively process it */ if (strlen(boundary)>0) { diff --git a/citadel/mime_parser.h b/citadel/mime_parser.h index 84dfdeef3..67e3afc65 100644 --- a/citadel/mime_parser.h +++ b/citadel/mime_parser.h @@ -1,6 +1,6 @@ void extract_key(char *target, char *source, char *key); -void mime_parser(char *content, +void mime_parser(char *content_start, char *content_end, void (*CallBack) (char *cbname, char *cbfilename, diff --git a/citadel/msgbase.c b/citadel/msgbase.c index f59ef82ac..8cdcf8b6a 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -551,7 +551,7 @@ time_t output_message(char *msgid, int mode, int headers_only) { /* do some sort of MIME output */ if ( (mode == MT_MIME) && (format_type == 4) ) { - mime_parser(mptr, *part_handler); + mime_parser(mptr, NULL, *part_handler); cprintf("000\n"); cdb_free(dmsgtext); return(xtime);