From 720cc070f9bb5cdfd5f5f90c8a209efeed146fae Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 27 Feb 2008 21:38:05 +0000 Subject: [PATCH] Multipart/alternative (possibly nested inside multipart/mixed) --- webcit/Makefile.in | 2 +- webcit/html.c | 33 +-------------------- webcit/html.h | 6 ---- webcit/messages.c | 71 ++++++++++++++++++++++++++++------------------ webcit/webcit.h | 2 ++ 5 files changed, 47 insertions(+), 67 deletions(-) delete mode 100644 webcit/html.h diff --git a/webcit/Makefile.in b/webcit/Makefile.in index abb8efbb6..59bf665c4 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -51,7 +51,7 @@ webserver: webserver.o context_loop.o ical_dezonify.o \ groupdav_main.o groupdav_get.o groupdav_propfind.o fmt_date.o \ groupdav_options.o autocompletion.o gettext.o tabs.o sieve.o \ groupdav_delete.o groupdav_put.o http_datestring.o setup_wizard.o \ - downloads.o addressbook_popup.o pushemail.o sysdep.o html.o\ + downloads.o addressbook_popup.o pushemail.o sysdep.o html.o \ $(LIBOBJS) $(CC) webserver.o context_loop.o cookie_conversion.o \ webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o listsub.o \ diff --git a/webcit/html.c b/webcit/html.c index 19cd38d89..034e08017 100644 --- a/webcit/html.c +++ b/webcit/html.c @@ -6,38 +6,7 @@ * released under the terms of the GNU General Public License. */ -#include "sysdep.h" -#include -#include -#include -#include -#include - -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -#include -#include -#include -#include -#include -#include "citadel.h" -#include "server.h" -#include "control.h" -#include "sysdep_decls.h" -#include "support.h" -#include "config.h" -#include "msgbase.h" -#include "room_ops.h" -#include "html.h" +#include "webcit.h" /* diff --git a/webcit/html.h b/webcit/html.h deleted file mode 100644 index 10f714d8e..000000000 --- a/webcit/html.h +++ /dev/null @@ -1,6 +0,0 @@ -/* - * $Id: html.h 5148 2007-05-08 15:40:16Z ajc $ - * - */ - -char *html_to_ascii(char *inputmsg, int msglen, int screenwidth, int do_citaformat); diff --git a/webcit/messages.c b/webcit/messages.c index 2bf9619c1..f22d0f16d 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -10,7 +10,6 @@ #include "webcit.h" #include "webserver.h" #include "groupdav.h" -#include "html.h" #define SUBJ_COL_WIDTH_PCT 50 /**< Mailbox view column width */ #define SENDER_COL_WIDTH_PCT 30 /**< Mailbox view column width */ @@ -2851,14 +2850,26 @@ DONE: * ... this is where the actual message gets transmitted to the server. */ void post_mime_to_server(void) { - char boundary[SIZ]; + char top_boundary[SIZ]; + char alt_boundary[SIZ]; int is_multipart = 0; static int seq = 0; struct wc_attachment *att; char *encoded; - char *txtmail; size_t encoded_length; size_t encoded_strlen; + char *txtmail = NULL; + + sprintf(top_boundary, "Citadel--Multipart--%s--%04x--%04x", + serv_info.serv_fqdn, + getpid(), + ++seq + ); + sprintf(alt_boundary, "Citadel--Multipart--%s--%04x--%04x", + serv_info.serv_fqdn, + getpid(), + ++seq + ); /** RFC2045 requires this, and some clients look for it... */ serv_puts("MIME-Version: 1.0"); @@ -2869,23 +2880,30 @@ void post_mime_to_server(void) { is_multipart = 1; } -// if (is_multipart) { - sprintf(boundary, "Citadel--Multipart--%s--%04x--%04x", - serv_info.serv_fqdn, - getpid(), - ++seq - ); - + if (is_multipart) { /** Remember, serv_printf() appends an extra newline */ - if (is_multipart) - serv_printf("Content-type: multipart/mixed; " - "boundary=\"%s\"\n", boundary); - else - serv_printf("Content-type: multipart/alternative; " - "boundary=\"%s\"\n", boundary); + serv_printf("Content-type: multipart/mixed; " + "boundary=\"%s\"\n", top_boundary); serv_printf("This is a multipart message in MIME format.\n"); - serv_printf("--%s", boundary); -// } + serv_printf("--%s", top_boundary); + } + + + + /* Remember, serv_printf() appends an extra newline */ + serv_printf("Content-type: multipart/alternative; " + "boundary=\"%s\"\n", alt_boundary); + serv_printf("This is a multipart message in MIME format.\n"); + serv_printf("--%s", alt_boundary); + + serv_puts("Content-type: text/plain; charset=utf-8"); + serv_puts("Content-Transfer-Encoding: quoted-printable"); + serv_puts(""); + txtmail = html_to_ascii(bstr("msgtext"), 0, 80, 0); + text_to_server_qp(txtmail); /** Transmit message in quoted-printable encoding */ + free(txtmail); + + serv_printf("--%s", alt_boundary); serv_puts("Content-type: text/html; charset=utf-8"); serv_puts("Content-Transfer-Encoding: quoted-printable"); @@ -2894,15 +2912,12 @@ void post_mime_to_server(void) { text_to_server_qp(bstr("msgtext")); /** Transmit message in quoted-printable encoding */ serv_puts("\r\n"); - serv_puts("Content-type: text/plain; charset=utf-8"); - serv_puts("Content-Transfer-Encoding: quoted-printable"); - serv_puts(""); - txtmail = html_to_ascii(bstr("msgtext"), 0, 80, 0); - text_to_server_qp(txtmail); /** Transmit message in quoted-printable encoding */ - free(txtmail); - if (!is_multipart) - serv_printf("--%s", boundary); + serv_printf("--%s--", alt_boundary); + + + + if (is_multipart) { @@ -2914,7 +2929,7 @@ void post_mime_to_server(void) { if (encoded == NULL) break; encoded_strlen = CtdlEncodeBase64(encoded, att->data, att->length, 1); - serv_printf("--%s", boundary); + serv_printf("--%s", top_boundary); serv_printf("Content-type: %s", att->content_type); serv_printf("Content-disposition: attachment; " "filename=\"%s\"", att->filename); @@ -2925,7 +2940,7 @@ void post_mime_to_server(void) { serv_puts(""); free(encoded); } - serv_printf("--%s--", boundary); + serv_printf("--%s--", top_boundary); } serv_puts("000"); diff --git a/webcit/webcit.h b/webcit/webcit.h index d47d6a830..890e432dd 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -760,6 +760,8 @@ void display_wiki_page(void); int get_time_format_cached (void); int xtoi(char *in, size_t len); void webcit_fmt_date(char *buf, time_t thetime, int brief); +char *html_to_ascii(char *inputmsg, int msglen, int screenwidth, int do_citaformat); + #ifdef HAVE_ICONV iconv_t ctdl_iconv_open(const char *tocode, const char *fromcode); -- 2.30.2