* More changes required to be able to do embedded message/rfc822 and still be
authorArt Cancro <ajc@citadel.org>
Sat, 22 Oct 2005 05:02:13 +0000 (05:02 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 22 Oct 2005 05:02:13 +0000 (05:02 +0000)
  able to view the attachments in the embedded submessage.   Yow.
* Brought over the updated MIME parser from the Citadel package.

webcit/ChangeLog
webcit/html2html.c
webcit/messages.c
webcit/mime_parser.c
webcit/rss.c

index 302cd218d0d4b8dd9bfe25c4a2310f518708f210..0552b742e40b5ff570907c2b2c467092edfb774c 100644 (file)
@@ -1,3 +1,8 @@
+Sat Oct 22 01:01:02 EDT 2005 ajc
+* More changes required to be able to do embedded message/rfc822 and still be
+  able to view the attachments in the embedded submessage.   Yow.
+* Brought over the updated MIME parser from the Citadel package.
+
 Fri Oct 21 15:25:49 EDT 2005 ajc
 * Handle embedded message/rfc822 submessages, using the new form of MSG4 on
   the Citadel server that can extract these for us.  There is still a bug or
index 32f76777f561bae82db7431c205951a2d25efe53..0e6dad744306977003bf54e3249279aeaf7e18d0 100644 (file)
@@ -63,10 +63,12 @@ void output_html(char *charset) {
 
 #ifdef HAVE_ICONV
        if ( (strcasecmp(charset, "us-ascii"))
-          && (strcasecmp(charset, "UTF-8")) ) {
+          && (strcasecmp(charset, "UTF-8"))
+          && (strcasecmp(charset, ""))
+       ) {
                ic = iconv_open("UTF-8", charset);
                if (ic == (iconv_t)(-1) ) {
-                       lprintf(5, "iconv_open() failed: %s\n", strerror(errno));
+                       lprintf(5, "%s:%d iconv_open() failed: %s\n", __FILE__, __LINE__, strerror(errno));
                }
        }
        if (ic != (iconv_t)(-1) ) {
index 66c8aa7a1530fedddb1aa14fe72c9df8732eebb0..2dcd3ca42aa21f72fc0726c835dc8528a8bc0741 100644 (file)
@@ -671,11 +671,12 @@ void read_message(long msgnum, int printable_view, char *section) {
                                        "TARGET=\"wc.%ld.%s\">"
                                        "<IMG SRC=\"/static/diskette_24x.gif\" "
                                        "BORDER=0 ALIGN=MIDDLE>\n"
-                                       "Part %s: %s (%s, %d bytes)</A><br />\n",
+                                       "%s (%s, %d bytes)</A><br />\n",
                                        msgnum, mime_partnum, mime_filename,
                                        msgnum, mime_partnum,
-                                       mime_partnum, mime_filename,
-                                       mime_content_type, mime_length);
+                                       mime_filename,
+                                       mime_content_type, mime_length
+                               );
                        }
 
                        /*** begin handler prep ***/
@@ -847,11 +848,14 @@ void read_message(long msgnum, int printable_view, char *section) {
 
        /* Set up a character set conversion if we need to (and if we can) */
 #ifdef HAVE_ICONV
+       if (strchr(mime_charset, ';')) strcpy(strchr(mime_charset, ';'), "");
        if ( (strcasecmp(mime_charset, "us-ascii"))
-          && (strcasecmp(mime_charset, "UTF-8")) ) {
+          && (strcasecmp(mime_charset, "UTF-8"))
+          && (strcasecmp(mime_charset, ""))
+       ) {
                ic = iconv_open("UTF-8", mime_charset);
                if (ic == (iconv_t)(-1) ) {
-                       lprintf(5, "iconv_open() failed: %s\n", strerror(errno));
+                       lprintf(5, "%s:%d iconv_open(UTF-8, %s) failed: %s\n", __FILE__, __LINE__, mime_charset, strerror(errno));
                }
        }
 #endif
@@ -914,7 +918,7 @@ void read_message(long msgnum, int printable_view, char *section) {
        }
 
        /* If there are attached submessages, display them now... */
-       if (strlen(mime_submessages) > 0) {
+       if ( (strlen(mime_submessages) > 0) && (!section[0]) ) {
                for (i=0; i<num_tokens(mime_submessages, '|'); ++i) {
                        extract_token(buf, mime_submessages, i, '|', sizeof buf);
                        /* use printable_view to suppress buttons */
@@ -925,9 +929,8 @@ void read_message(long msgnum, int printable_view, char *section) {
        }
 
 
-
        /* Afterwards, offer links to download attachments 'n' such */
-       if (strlen(mime_http) > 0) {
+       if ( (strlen(mime_http) > 0) && (!section[0]) ) {
                wprintf("%s", mime_http);
        }
 
@@ -1200,10 +1203,12 @@ void pullquote_message(long msgnum, int forward_attachments) {
        /* Set up a character set conversion if we need to (and if we can) */
 #ifdef HAVE_ICONV
        if ( (strcasecmp(mime_charset, "us-ascii"))
-          && (strcasecmp(mime_charset, "UTF-8")) ) {
+          && (strcasecmp(mime_charset, "UTF-8"))
+          && (strcasecmp(mime_charset, ""))
+       ) {
                ic = iconv_open("UTF-8", mime_charset);
                if (ic == (iconv_t)(-1) ) {
-                       lprintf(5, "iconv_open() failed: %s\n", strerror(errno));
+                       lprintf(5, "%s:%d iconv_open() failed: %s\n", __FILE__, __LINE__, strerror(errno));
                }
        }
 #endif
index 1c82b001a2462b04673df5c80a9725d3920109c5..f3fb942bd8384ba163e9227478a8955b7975e548 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * This is the MIME parser for Citadel.  Sometimes it actually works.
+ * This is the MIME parser for Citadel.
  *
  * Copyright (c) 1998-2005 by Art Cancro
  * This code is distributed under the terms of the GNU General Public License.
@@ -397,7 +397,6 @@ void the_mime_parser(char *partnum,
 
                part_start = NULL;
                do {
-       
                        next_boundary = NULL;
                        for (srch=ptr; srch<content_end; ++srch) {
                                if (!memcmp(srch, startary, startary_len)) {
@@ -465,9 +464,9 @@ void the_mime_parser(char *partnum,
                        ++length;
                }
                part_end = content_end;
-                /* fix an off-by-one error */
-                --part_end;
-                --length;
+               /* fix an off-by-one error */
+               --part_end;
+               --length;
                
                /* Truncate if the header told us to */
                if ( (content_length > 0) && (length > content_length) ) {
@@ -484,13 +483,61 @@ void the_mime_parser(char *partnum,
                else {
                        name = content_type_name;
                }
-               
+       
+               /*
+               lprintf(9, "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.
+                */
                mime_decode(partnum,
-                           part_start, length,
-                           content_type, charset, encoding, disposition,
-                           name, filename,
-                           CallBack, NULL, NULL,
-                           userdata, dont_decode);
+                       part_start, length,
+                       content_type, charset, encoding, disposition,
+                       name, filename,
+                       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 0e71987f2401c8a6e20fdb8d06ec1512ac1bf189..fe4a5d7a01306348c076761e7c21c33c1f364cbd 100644 (file)
@@ -232,10 +232,10 @@ void display_rss(char *roomname, char *request_method)
 
                /* Set up a character set conversion if we need to */
 #ifdef HAVE_ICONV
-               if (strcasecmp(charset, "us-ascii") && strcasecmp(charset, "utf-8")) {
+               if (strcasecmp(charset, "us-ascii") && strcasecmp(charset, "utf-8") && strcasecmp(charset, "") ) {
                        ic = iconv_open("UTF-8", charset);
                        if (ic == (iconv_t)(-1)) {
-                               lprintf(5, "iconv_open() failed: %s\n", strerror(errno));
+                               lprintf(5, "%s:%d iconv_open() failed: %s\n", __FILE__, __LINE__, strerror(errno));
                                goto ENDBODY;
                        }
                }