+Sat Oct 22 00:46:52 EDT 2005 ajc
+* mime_parser.c: recurse into message/rfc822 parts as if they were
+ multipart, because we may need to extract attachments from the embedded
+ submessage, etc. (uuuuunnnhhhh...)
+
Fri Oct 21 15:12:45 EDT 2005 ajc
* MSG4 (and CtdlOutputMsg() as well) now accepts an optional MIME part
specifier, allowing the client to fetch an encapsulated message
name = content_type_name;
}
- /* lprintf(CTDL_DEBUG, "mime_decode part=%s, len=%d, type=%s, charset=%s, encoding=%s\n",
- partnum, length, content_type, charset, encoding); */
+ lprintf(CTDL_DEBUG, "mime_decode part=%s, len=%d, type=%s, charset=%s, encoding=%s\n",
+ partnum, length, content_type, charset, encoding);
/* Ok, we've got a non-multipart part here, so do something with it.
*/
CallBack, NULL, NULL,
userdata, dont_decode
);
+
+ /*
+ * Now if it's an encapsulated message/rfc822 then we have to recurse into it
+ */
+ if (!strcasecmp(content_type, "message/rfc822")) {
+
+ if (PreMultiPartCallBack != NULL) {
+ PreMultiPartCallBack("", "", partnum, "",
+ NULL, content_type, charset,
+ 0, encoding, userdata);
+ }
+ if (CallBack != NULL) {
+ if (strlen(partnum) > 0) {
+ snprintf(nested_partnum,
+ sizeof nested_partnum,
+ "%s.%d", partnum,
+ ++part_seq);
+ }
+ else {
+ snprintf(nested_partnum,
+ sizeof nested_partnum,
+ "%d", ++part_seq);
+ }
+ the_mime_parser(nested_partnum,
+ part_start, part_end,
+ CallBack,
+ PreMultiPartCallBack,
+ PostMultiPartCallBack,
+ userdata,
+ dont_decode
+ );
+ }
+ if (PostMultiPartCallBack != NULL) {
+ PostMultiPartCallBack("", "", partnum, "", NULL,
+ content_type, charset, 0, encoding, userdata);
+ }
+
+
+ }
+
}
end_parser: /* free the buffers! end the oppression!! */
for (i=0; i<num_tokens(CC->preferred_formats, '|'); ++i) {
extract_token(buf, CC->preferred_formats, i, '|', sizeof buf);
if (!strcasecmp(buf, cbtype)) {
- strcpy(ma->chosen_part, partnum);
+ if (num_tokens(partnum, '.') < 3) {
+ lprintf(CTDL_DEBUG, "REPLACING MA <%s> WITH <%s>\n",
+ ma->chosen_part, partnum);
+ safestrncpy(ma->chosen_part, partnum, sizeof ma->chosen_part);
+ }
}
}
}