From: Art Cancro Date: Sun, 13 Jan 2002 09:06:38 +0000 (+0000) Subject: * Brought over the debugged mime parser from Citadel X-Git-Tag: v7.86~6609 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=f228abbeff3182ad5e320983a1d1d4ded012f1a2 * Brought over the debugged mime parser from Citadel --- diff --git a/webcit/ChangeLog b/webcit/ChangeLog index cc0786f20..a463b3f2d 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,7 @@ $Log$ +Revision 322.4 2002/01/13 09:06:38 ajc +* Brought over the debugged mime parser from Citadel + Revision 322.3 2002/01/05 06:19:17 error * Add MIME types text/css and image/png @@ -707,4 +710,3 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix - diff --git a/webcit/README.txt b/webcit/README.txt index b561bd0ca..1a96ad1d2 100644 --- a/webcit/README.txt +++ b/webcit/README.txt @@ -1,5 +1,5 @@ WEBCIT for the Citadel/UX System - version 3.22 + version 3.23 Copyright (C) 1996-2001 by the authors. Portions written by: Art Cancro diff --git a/webcit/mime_parser.c b/webcit/mime_parser.c index 021d5e52b..2fa52d9a1 100644 --- a/webcit/mime_parser.c +++ b/webcit/mime_parser.c @@ -3,7 +3,7 @@ * * This is the MIME parser for Citadel. Sometimes it actually works. * - * Copyright (c) 1998-2001 by Art Cancro + * Copyright (c) 1998-2002 by Art Cancro * This code is distributed under the terms of the GNU General Public License. * */ @@ -17,9 +17,7 @@ #include #include #include -#include #include "webcit.h" -#include "mime_parser.h" void extract_key(char *target, char *source, char *key) @@ -166,6 +164,8 @@ void mime_decode(char *partnum, char *decoded; size_t bytes_decoded = 0; + fprintf(stderr, "mime_decode() called\n"); + /* Some encodings aren't really encodings */ if (!strcasecmp(encoding, "7bit")) strcpy(encoding, ""); @@ -183,6 +183,7 @@ void mime_decode(char *partnum, } return; } + if ((strcasecmp(encoding, "base64")) && (strcasecmp(encoding, "quoted-printable"))) { fprintf(stderr, "ERROR: unknown MIME encoding '%s'\n", encoding); @@ -192,15 +193,18 @@ void mime_decode(char *partnum, * Allocate a buffer for the decoded data. The output buffer is the * same size as the input buffer; this assumes that the decoded data * will never be larger than the encoded data. This is a safe - * assumption with base64, uuencode, and quoted-printable. Just to - * be safe, we still pad the buffer a bit. + * assumption with base64, uuencode, and quoted-printable. */ - decoded = malloc(length + 1024); + fprintf(stderr, "About to allocate %d bytes for decoded part\n", + length+2048); + decoded = malloc(length+2048); if (decoded == NULL) { fprintf(stderr, "ERROR: cannot allocate memory.\n"); return; } + fprintf(stderr, "Got it!\n"); + fprintf(stderr, "Decoding %s\n", encoding); if (!strcasecmp(encoding, "base64")) { bytes_decoded = decode_base64(decoded, part_start); } @@ -208,6 +212,7 @@ void mime_decode(char *partnum, bytes_decoded = decode_quoted_printable(decoded, part_start, length); } + fprintf(stderr, "Bytes decoded: %d\n", bytes_decoded); if (bytes_decoded > 0) if (CallBack != NULL) { CallBack(name, filename, fixed_partnum(partnum), @@ -218,9 +223,6 @@ void mime_decode(char *partnum, free(decoded); } - - - /* * Break out the components of a multipart message * (This function expects to be fed HEADERS + CONTENT) @@ -322,7 +324,7 @@ void the_mime_parser(char *partnum, /* Learn interesting things from the headers */ strcpy(header, ""); do { - ptr = memreadline(ptr, buf, sizeof buf); + ptr = memreadline(ptr, buf, SIZ); if (ptr >= content_end) { goto end_parser; } @@ -351,7 +353,7 @@ void the_mime_parser(char *partnum, extract_key(boundary, header, "boundary"); strcpy(header, ""); } - if ((strlen(header) + strlen(buf) + 2) < sizeof(header)) + if ((strlen(header) + strlen(buf) + 2) < SIZ) strcat(header, buf); } while ((strlen(buf) > 0) && (*ptr != 0)); @@ -410,7 +412,7 @@ void the_mime_parser(char *partnum, userdata, dont_decode); } - ptr = memreadline(ptr, buf, sizeof(buf)); + ptr = memreadline(ptr, buf, SIZ); part_start = ptr; } else { @@ -464,10 +466,6 @@ end_parser: /* free the buffers! end the oppression!! */ - - - - /* * Entry point for the MIME parser. * (This function expects to be fed HEADERS + CONTENT) diff --git a/webcit/webcit.h b/webcit/webcit.h index 522a48193..d7f809615 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -7,10 +7,10 @@ #define SLEEPING 180 /* TCP connection timeout */ #define WEBCIT_TIMEOUT 900 /* WebCit session timeout */ #define PORT_NUM 2000 /* port number to listen on */ -#define SERVER "WebCit v3.22" /* who's in da house */ +#define SERVER "WebCit v3.23" /* who's in da house */ #define DEVELOPER_ID 0 #define CLIENT_ID 4 -#define CLIENT_VERSION 322 +#define CLIENT_VERSION 323 #define DEFAULT_HOST "localhost" /* Default Citadel server */ #define DEFAULT_PORT "504" #define LB (1) /* Internal escape chars */