* msgbase.c: Yet Another Fix to the handling of embedded message/rfc822
authorArt Cancro <ajc@citadel.org>
Wed, 26 Oct 2005 17:22:36 +0000 (17:22 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 26 Oct 2005 17:22:36 +0000 (17:22 +0000)
citadel/ChangeLog
citadel/msgbase.c
citadel/msgbase.h

index e71800221a3cb2b86bda43179da6de5ba49072c5..475e541b7cfe0985d7e34383a38e6c30397defb4 100644 (file)
@@ -1,5 +1,8 @@
 $Id$
 
+Wed Oct 26 13:22:02 EDT 2005 ajc
+* msgbase.c: Yet Another Fix to the handling of embedded message/rfc822
+
 Tue Oct 25 17:29:12 EDT 2005 ajc
 * msgbase.c: when a summary mode message list is requested, and the room
   contains a pointer to a message which does not exist (this normally should
index f09afc41dafe3bbda73771499a29d74964109faa..e6c25a872b4f460b3b9dd44b40fb0e5333e9cc82 100644 (file)
@@ -1066,7 +1066,9 @@ void fixed_output_pre(char *name, char *filename, char *partnum, char *disp,
        if (!strcasecmp(cbtype, "multipart/alternative")) {
                ++ma->is_ma;
                ma->did_print = 0;
-               return;
+       }
+       if (!strcasecmp(cbtype, "message/rfc822")) {
+               ++ma->freeze;
        }
 }
 
@@ -1084,7 +1086,9 @@ void fixed_output_post(char *name, char *filename, char *partnum, char *disp,
        if (!strcasecmp(cbtype, "multipart/alternative")) {
                --ma->is_ma;
                ma->did_print = 0;
-       return;
+       }
+       if (!strcasecmp(cbtype, "message/rfc822")) {
+               --ma->freeze;
        }
 }
 
@@ -1110,7 +1114,7 @@ void fixed_output(char *name, char *filename, char *partnum, char *disp,
         * If we're in the middle of a multipart/alternative scope and
         * we've already printed another section, skip this one.
         */     
-       if ( (ma->is_ma == 1) && (ma->did_print == 1) ) {
+       if ( (ma->is_ma) && (ma->did_print) ) {
                lprintf(CTDL_DEBUG, "Skipping part %s (%s)\n",
                        partnum, cbtype);
                return;
@@ -1163,10 +1167,8 @@ void choose_preferred(char *name, char *filename, char *partnum, char *disp,
        if (ma->is_ma > 0) {
                for (i=0; i<num_tokens(CC->preferred_formats, '|'); ++i) {
                        extract_token(buf, CC->preferred_formats, i, '|', sizeof buf);
-                       if (!strcasecmp(buf, cbtype)) {
-                               if (num_tokens(partnum, '.') < 3) {
-                                       safestrncpy(ma->chosen_part, partnum, sizeof ma->chosen_part);
-                               }
+                       if ( (!strcasecmp(buf, cbtype)) && (!ma->freeze) ) {
+                               safestrncpy(ma->chosen_part, partnum, sizeof ma->chosen_part);
                        }
                }
        }
index 2801813d36e637394bd027deb81f6048fb90dc03..64feab384fee73f046e59b9072cf753ed53eed98 100644 (file)
@@ -31,6 +31,8 @@ enum {
 
 struct ma_info {
        int is_ma;              /* Set to 1 if we are using this stuff */
+       int freeze;             /* Freeze the replacement chain because we're
+                                * digging through a subsection */
        int did_print;          /* One alternative has been displayed */
        char chosen_part[128];  /* Which part of a m/a did we choose? */
 };