}
else {
content_length = StrLength(Source);
+ free(msg);
msg = (char*) ChrPtr(Source);/* TODO: remove cast */
buffer_length = content_length;
}
strcpy(msg, msgstart);
}
+ /** Now go through the message, parsing tags as necessary. */
+ converted_msg = NewStrBufPlain(NULL, content_length + 8192);
+
+
/** Convert foreign character sets to UTF-8 if necessary. */
#ifdef HAVE_ICONV
if ( (strcasecmp(charset, "us-ascii"))
__FILE__, __LINE__, strerror(errno));
}
}
- if (ic != (iconv_t)(-1) ) {
- ibuf = msg;
- ibuflen = content_length;
- obuflen = content_length + (content_length / 2) ;
- obuf = (char *) malloc(obuflen);
- osav = obuf;
- iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
- content_length = content_length + (content_length / 2) - obuflen;
- osav[content_length] = 0;
- free(msg);
- msg = osav;
- iconv_close(ic);
+ if (Source == NULL) {
+ if (ic != (iconv_t)(-1) ) {
+ ibuf = msg;
+ ibuflen = content_length;
+ obuflen = content_length + (content_length / 2) ;
+ obuf = (char *) malloc(obuflen);
+ osav = obuf;
+ iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
+ content_length = content_length + (content_length / 2) - obuflen;
+ osav[content_length] = 0;
+ free(msg);
+ msg = osav;
+ iconv_close(ic);
+ }
+ }
+ else {
+ if (ic != (iconv_t)(-1) ) {
+ StrBuf *Buf = NewStrBufPlain(NULL, StrLength(Source) + 8096);;
+ StrBufConvert(Source, Buf, &ic);
+ FreeStrBuf(&Buf);
+ iconv_close(ic);
+ }
}
+
#endif
/**
* terminated now.
*/
- /** Now go through the message, parsing tags as necessary. */
- converted_msg = NewStrBufPlain(NULL, content_length + 8192);
if (converted_msg == NULL) {
StrBufAppendPrintf(Target, "Error %d: %s<br />%s:%d", errno, strerror(errno), __FILE__, __LINE__);
goto BAIL;
* message index functions
*/
+void DestroyMimeParts(wc_mime_attachment *Mime)
+{
+ FreeStrBuf(&Mime->Name);
+ FreeStrBuf(&Mime->FileName);
+ FreeStrBuf(&Mime->PartNum);
+ FreeStrBuf(&Mime->Disposition);
+ FreeStrBuf(&Mime->ContentType);
+ FreeStrBuf(&Mime->Charset);
+ FreeStrBuf(&Mime->Data);
+}
-
+void DestroyMime(void *vMime)
+{
+ wc_mime_attachment *Mime = (wc_mime_attachment*)vMime;
+ DestroyMimeParts(Mime);
+ free(Mime);
+}
void DestroyMessageSummary(void *vMsg)
{
FreeStrBuf(&Msg->Rfca);
FreeStrBuf(&Msg->OtherNode);
+ FreeStrBuf(&Msg->reply_to);
+
+ DeleteHash(&Msg->Attachments); /**< list of Accachments */
+ DeleteHash(&Msg->Submessages);
+ DeleteHash(&Msg->AttachLinks);
+
+ DestroyMimeParts(&Msg->MsgBody);
+
free(Msg);
}
mime = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
memset(mime, 0, sizeof(wc_mime_attachment));
- Buf=NewStrBuf();
+ Buf = NewStrBuf();
mime->Name = NewStrBuf();
StrBufExtract_token(mime->Name, HdrLine, 0, '|');
+
StrBufExtract_token(Buf, HdrLine, 1, '|');
StrBuf_RFC822_to_Utf8(mime->FileName, Buf, WC->DefaultCharset, FoundCharset);
+
mime->PartNum = NewStrBuf();
StrBufExtract_token(mime->PartNum, HdrLine, 2, '|');
+
mime->Disposition = NewStrBuf();
StrBufExtract_token(mime->Disposition, HdrLine, 3, '|');
+
mime->ContentType = NewStrBuf();
StrBufExtract_token(mime->ContentType, HdrLine, 4, '|');
+
mime->length = StrBufExtract_int(HdrLine, 5, '|');
StrBufTrim(mime->Name);
StrBufTrim(mime->FileName);
+
if ( (StrLength(mime->FileName) == 0) && (StrLength(mime->Name) > 0) ) {
StrBufAppendBuf(mime->FileName, mime->Name, 0);
}
Msg->cal_partnum_ref = mime;
}
/** end handler prep ***/
+
+ FreeStrBuf(&Buf);
+
}
void tmplput_MAIL_SUMM_NATTACH(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
{
StrBuf *Buf;
StrBuf *Token;
StrBuf *FoundCharset;
- message_summary *Msg;
+ message_summary *Msg = NULL;
headereval *Hdr;
void *vHdr;
char buf[SIZ];
break;
}
}
-
-
- if (GetHash(MimeRenderHandler, SKEY(Msg->MsgBody.ContentType), &vHdr) &&
+
+ /* strip the bare contenttype, so we ommit charset etc. */
+ StrBufExtract_token(Buf, Msg->MsgBody.ContentType, 0, ';');
+ StrBufTrim(Buf);
+ if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
(vHdr != NULL)) {
RenderMimeFunc Render;
Render = (RenderMimeFunc)vHdr;
if (nhdr == 1) {
wprintf("****");
}
-
- if (StrLength(Msg->cccc)> 0) {
- StrBuf *tmp;
- tmp = Msg->cccc;
- Msg->cccc = Buf;
- StrBuf_RFC822_to_Utf8(Msg->cccc, tmp, WCC->DefaultCharset, FoundCharset);
- Buf = tmp;
- }
- if (StrLength(Msg->subj)> 0) {
- StrBuf *tmp;
- tmp = Msg->subj;
- Msg->subj = Buf;
- StrBuf_RFC822_to_Utf8(Msg->subj, tmp, WCC->DefaultCharset, FoundCharset);
- Buf = tmp;
- }
-
DoTemplate(HKEY("view_message"), NULL, Msg, CTX_MAILSUM);
if (num_attach_links > 0) {
free(attach_links);
}
+ DestroyMessageSummary(Msg);
FreeStrBuf(&FoundCharset);
+ FreeStrBuf(&Token);
+ FreeStrBuf(&Buf);
}
int follow_xff = 0; /* Follow X-Forwarded-For: header */
int home_specified = 0; /* did the user specify a homedir? */
int time_to_die = 0; /* Nonzero if server is shutting down */
+int DisableGzip = 0;
extern void *context_loop(int*);
extern void *housekeeping_loop(void);
extern pthread_mutex_t SessionListMutex;
#ifdef HAVE_ZLIB
/* Perform gzip compression, if enabled and supported by client */
- if ((WCC->gzip_ok) && CompressBuffer(WCC->WBuf))
+ if (!DisableGzip && (WCC->gzip_ok) && CompressBuffer(WCC->WBuf))
{
hprintf("Content-encoding: gzip\r\n");
}
LoadZoneFiles();
-
#ifdef DBG_PRINNT_HOOKS_AT_START
dbg_PrintHash(HandlerHash, nix, NULL);
#endif
/* Parse command line */
#ifdef HAVE_OPENSSL
- while ((a = getopt(argc, argv, "h:i:p:t:T:x:dD:cfs")) != EOF)
+ while ((a = getopt(argc, argv, "h:i:p:t:T:x:dD:cfsZ")) != EOF)
#else
- while ((a = getopt(argc, argv, "h:i:p:t:T:x:dD:cf")) != EOF)
+ while ((a = getopt(argc, argv, "h:i:p:t:T:x:dD:cfZ")) != EOF)
#endif
switch (a) {
case 'h':
case 'T':
LoadTemplates = atoi(optarg);
break;
+ case 'Z':
+ DisableGzip = 1;
+ break;
case 'x':
verbosity = atoi(optarg);
break;