* mime_parser.c: recurse into message/rfc822 parts as if they were
authorArt Cancro <ajc@citadel.org>
Sat, 22 Oct 2005 04:48:03 +0000 (04:48 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 22 Oct 2005 04:48:03 +0000 (04:48 +0000)
  multipart, because we may need to extract attachments from the embedded
  submessage, etc.  (uuuuunnnhhhh...)

citadel/ChangeLog
citadel/mime_parser.c
citadel/msgbase.c
citadel/msgbase.h

index e1afd2ed737fafcdc9c92d94c3d725c516608c0d..118fcb27645ceaa77e77edce08a9ebada3c9a419 100644 (file)
@@ -1,3 +1,8 @@
+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
index edbdc52cb0bc0773d17ad246128d9e7ebac32ccf..d43690685e3175aadd7eb5c41b8184c8f33ab8e3 100644 (file)
@@ -498,8 +498,8 @@ void the_mime_parser(char *partnum,
                        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.
                 */
@@ -510,6 +510,46 @@ void the_mime_parser(char *partnum,
                        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!! */
index 51d78547b73f0d7ca55045e18f9d07d2fd7b4d07..31ccb60d6c32f4ade3d8b1540158c0626bbb0e91 100644 (file)
@@ -1168,7 +1168,11 @@ void choose_preferred(char *name, char *filename, char *partnum, char *disp,
                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);
+                               }
                        }
                }
        }
index 600b684dc3e273bc648aaff262a4ae5a14858cf1..2801813d36e637394bd027deb81f6048fb90dc03 100644 (file)
@@ -32,7 +32,7 @@ enum {
 struct ma_info {
        int is_ma;              /* Set to 1 if we are using this stuff */
        int did_print;          /* One alternative has been displayed */
-       char chosen_part[SIZ];  /* Which part of a m/a did we choose? */
+       char chosen_part[128];  /* Which part of a m/a did we choose? */
 };