From a1b27b35e581ec7abeeab6aae7acd1463583ea17 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 31 Aug 1999 00:57:18 +0000 Subject: [PATCH] * Handle multipart/alternative properly during legacy message outputs. Basically it just prints the first alternative and skips the rest. --- citadel/ChangeLog | 5 +++++ citadel/msgbase.c | 51 +++++++++++++++++++++++++++++++++++++---------- citadel/msgbase.h | 6 +++++- citadel/server.h | 1 + 4 files changed, 51 insertions(+), 12 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index add5206ef..fb1d4668d 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ +Revision 1.355 1999/08/31 00:57:17 ajc +* Handle multipart/alternative properly during legacy message outputs. + Basically it just prints the first alternative and skips the rest. + Revision 1.354 1999/08/29 21:12:24 ajc * Made some changes to the output of MIME (especially multipart) messages. @@ -1207,3 +1211,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/msgbase.c b/citadel/msgbase.c index afb09d3cc..deec85222 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -31,6 +31,7 @@ #include "html.h" #define desired_section ((char *)CtdlGetUserData(SYM_DESIRED_SECTION)) +#define ma ((struct ma_info *)CtdlGetUserData(SYM_MA_INFO)) extern struct config config; @@ -417,7 +418,7 @@ void memfmout(int width, char *mptr, char subst) } goto FMTA; - FMTEND:cprintf("%s\n", aaa); +FMTEND: cprintf("%s\n", aaa); } @@ -442,15 +443,32 @@ void fixed_output(char *name, char *filename, char *partnum, char *disp, { char *ptr; + if (!strcasecmp(cbtype, "multipart/alternative")) { + strcpy(ma->prefix, partnum); + strcat(ma->prefix, "."); + ma->is_ma = 1; + ma->did_print = 0; + return; + } + + if ( (!strncasecmp(partnum, ma->prefix, strlen(ma->prefix))) + && (ma->is_ma == 1) + && (ma->did_print == 1) ) { + lprintf(9, "Skipping part %s (%s)\n", partnum, cbtype); + return; + } + + ma->did_print = 1; + if (!strcasecmp(cbtype, "text/plain")) { client_write(content, length); } else if (!strcasecmp(cbtype, "text/html")) { - ptr = html_to_ascii(content, 80, 1); + ptr = html_to_ascii(content, 80, 0); client_write(ptr, strlen(ptr)); phree(ptr); } - else { + else if (strncasecmp(cbtype, "multipart/", 10)) { cprintf("Part %s: %s (%s) (%d bytes)\n", partnum, filename, cbtype, length); } @@ -600,6 +618,7 @@ void output_message(char *msgid, int mode, int headers_only) cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN); return; } + /* FIX ... small security issue * We need to check to make sure the requested message is actually * in the current room, and set msg_ok to 1 only if it is. This @@ -650,9 +669,17 @@ void output_message(char *msgid, int mode, int headers_only) /* now for the user-mode message reading loops */ cprintf("%d Message %ld:\n", LISTING_FOLLOWS, msg_num); - if (mode == MT_CITADEL) - cprintf("type=%d\n", TheMessage->cm_format_type); + /* Tell the client which format type we're using. If this is a + * MIME message, *lie* about it and tell the user it's fixed-format. + */ + if (mode == MT_CITADEL) { + if (TheMessage->cm_format_type == 4) + cprintf("type=1\n"); + else + cprintf("type=%d\n", TheMessage->cm_format_type); + } + /* nhdr=yes means that we're only displaying headers, no body */ if ((TheMessage->cm_anon_type == MES_ANON) && (mode == MT_CITADEL)) { cprintf("nhdr=yes\n"); } @@ -751,8 +778,7 @@ void output_message(char *msgid, int mode, int headers_only) } cprintf("Message-ID: <%s@%s>\n", mid, snode); PerformUserHooks(luser, (-1L), EVT_OUTPUTMSG); - cprintf("From: %s@%s (%s)\n", - suser, snode, luser); + cprintf("From: %s@%s (%s)\n", suser, snode, luser); cprintf("Organization: %s\n", lnode); } @@ -760,12 +786,13 @@ void output_message(char *msgid, int mode, int headers_only) mptr = TheMessage->cm_fields['M']; - /* do some sort of MIME output */ - if (TheMessage->cm_format_type == 4) { - if ((mode == MT_CITADEL) || (mode == MT_MIME)) { + /* Tell the client about the MIME parts in this message */ + if (TheMessage->cm_format_type == 4) { /* legacy textual dump */ + if (mode == MT_CITADEL) { mime_parser(mptr, NULL, *list_this_part); } - if (mode == MT_MIME) { /* If MT_MIME then it's parts only */ + else if (mode == MT_MIME) { /* list parts only */ + mime_parser(mptr, NULL, *list_this_part); cprintf("000\n"); CtdlFreeMessage(TheMessage); return; @@ -822,6 +849,8 @@ void output_message(char *msgid, int mode, int headers_only) * we use will display those parts as-is. */ if (TheMessage->cm_format_type == 4) { + CtdlAllocUserData(SYM_MA_INFO, sizeof(struct ma_info)); + memset(ma, 0, sizeof(struct ma_info)); mime_parser(mptr, NULL, *fixed_output); } diff --git a/citadel/msgbase.h b/citadel/msgbase.h index c2946d916..54c1e368a 100644 --- a/citadel/msgbase.h +++ b/citadel/msgbase.h @@ -47,4 +47,8 @@ void CtdlFreeMessage(struct CtdlMessage *msg); #define MSGS_LAST 4 #define MSGS_GT 5 - +struct ma_info { + char prefix[256]; /* Prefix for a multipart/alternative */ + int is_ma; /* Set to 1 if we are using this stuff */ + int did_print; /* One alternative has been displayed */ +}; diff --git a/citadel/server.h b/citadel/server.h index f3bf45242..909d02775 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -21,6 +21,7 @@ struct CtdlSessData { */ enum { SYM_DESIRED_SECTION, /* Used by the MIME parser */ + SYM_MA_INFO, /* Handles multipart/alternative */ SYM_MAX }; -- 2.30.2