From cc60870d487bc155b36165afc647d0c206cad4b8 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Sat, 13 Aug 2005 14:40:46 +0000 Subject: [PATCH] Added charset detecting --- mbfido/rfc2ftn.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mbfido/rfc2ftn.c b/mbfido/rfc2ftn.c index ec8abb1e..5a5fd4ba 100644 --- a/mbfido/rfc2ftn.c +++ b/mbfido/rfc2ftn.c @@ -124,7 +124,7 @@ int kludgewrite(char *s, FILE *fp) */ int rfc2ftn(FILE *fp, faddr *recipient) { - char sbe[16], *p, *q, *temp, *origin, newsubj[4 * (MAXSUBJ+1)], *oldsubj, *acup_a = NULL; + char sbe[16], *p, *q, *temp, *origin, newsubj[4 * (MAXSUBJ+1)], *oldsubj, *acup_a = NULL, *charset = NULL; int i, rc, newsmode, seenlen, oldnet; rfcmsg *msg = NULL, *tmsg, *tmp; ftnmsg *fmsg = NULL; @@ -216,8 +216,6 @@ int rfc2ftn(FILE *fp, faddr *recipient) while (*p && isspace(*p)) p++; - Syslog('m', "Content-Type: %s", printable(p, 0)); - /* * Check for mime to remove. */ @@ -229,6 +227,15 @@ int rfc2ftn(FILE *fp, faddr *recipient) q = strtok(p, " \n\0"); q = strtok(NULL, " \n\0"); Syslog('m', "charset part: %s", printable(q, 0)); + if (q && (strcasecmp(q, "charset=") == 0)) { + charset = xstrcpy(q + 8); + Syslog('m', "Charset \"%s\"", printable(charset, 0)); + } + } + + if (charset == NULL) { + charset = xstrcpy((char *)"iso-8859-1"); + Syslog('m', "No charset, setting default to iso-8859-1"); } if ((p = hdr((char *)"Message-ID",msg))) { @@ -704,7 +711,10 @@ int rfc2ftn(FILE *fp, faddr *recipient) free(origin); fclose(ofp); } while (needsplit); + free(temp); + if (charset) + free(charset); tidyrfc(msg); tidy_ftnmsg(fmsg); UpdateMsgs();