/**
* @ingroup StrBuf_DeEnCoder
- * @brief Handle subjects with RFC2047 encoding such as:
+ * @brief Handle subjects with RFC2047 encoding such as: [deprecated old syntax!]
* =?koi8-r?B?78bP0s3Mxc7JxSDXz9rE1dvO2c3JINvB0sHNySDP?=
* @param Target where to put the decoded string to
* @param DecodeMe buffer with encoded string
* put it here for later use where no string might be known.
*/
void StrBuf_RFC822_to_Utf8(StrBuf *Target, const StrBuf *DecodeMe, const StrBuf* DefaultCharset, StrBuf *FoundCharset)
+{
+ StrBuf *ConvertBuf;
+ StrBuf *ConvertBuf2;
+ ConvertBuf = NewStrBufPlain(NULL, StrLength(DecodeMe));
+ ConvertBuf2 = NewStrBufPlain(NULL, StrLength(DecodeMe));
+
+ StrBuf_RFC822_2_Utf8(Target,
+ DecodeMe,
+ DefaultCharset,
+ FoundCharset,
+ ConvertBuf,
+ ConvertBuf2);
+ FreeStrBuf(&ConvertBuf);
+ FreeStrBuf(&ConvertBuf2);
+}
+
+/**
+ * @ingroup StrBuf_DeEnCoder
+ * @brief Handle subjects with RFC2047 encoding such as:
+ * =?koi8-r?B?78bP0s3Mxc7JxSDXz9rE1dvO2c3JINvB0sHNySDP?=
+ * @param Target where to put the decoded string to
+ * @param DecodeMe buffer with encoded string
+ * @param DefaultCharset if we don't find one, which should we use?
+ * @param FoundCharset overrides DefaultCharset if non-empty; If we find a charset inside of the string,
+ * put it here for later use where no string might be known.
+ * @param ConvertBuf workbuffer. feed in, you shouldn't care about its content.
+ * @param ConvertBuf2 workbuffer. feed in, you shouldn't care about its content.
+ */
+void StrBuf_RFC822_2_Utf8(StrBuf *Target,
+ const StrBuf *DecodeMe,
+ const StrBuf* DefaultCharset,
+ StrBuf *FoundCharset,
+ StrBuf *ConvertBuf,
+ StrBuf *ConvertBuf2)
{
StrBuf *DecodedInvalidBuf = NULL;
- StrBuf *ConvertBuf, *ConvertBuf2;
const StrBuf *DecodeMee = DecodeMe;
const char *start, *end, *next, *nextend, *ptr = NULL;
#ifdef HAVE_ICONV
}
}
- ConvertBuf = NewStrBufPlain(NULL, StrLength(DecodeMe));
if ((illegal_non_rfc2047_encoding) &&
(strcasecmp(ChrPtr(DefaultCharset), "UTF-8")) &&
(strcasecmp(ChrPtr(DefaultCharset), "us-ascii")) )
end = FindNextEnd (DecodeMee, start);
else {
StrBufAppendBuf(Target, DecodeMee, 0);
- FreeStrBuf(&ConvertBuf);
FreeStrBuf(&DecodedInvalidBuf);
return;
}
- ConvertBuf2 = NewStrBufPlain(NULL, StrLength(DecodeMee));
if (start != DecodeMee->buf) {
long nFront;
if (ptr < nextend)
StrBufAppendBufPlain(Target, end, nextend - end, 0);
}
- FreeStrBuf(&ConvertBuf);
- FreeStrBuf(&ConvertBuf2);
FreeStrBuf(&DecodedInvalidBuf);
}
#include "webserver.h"
#include "groupdav.h"
+
+
+inline void CheckConvertBufs(struct wcsession *WCC)
+{
+ if (WCC->ConvertBuf1 == NULL)
+ WCC->ConvertBuf1 = NewStrBuf();
+ if (WCC->ConvertBuf2 == NULL)
+ WCC->ConvertBuf2 = NewStrBuf();
+}
+
/*
* message index functions
*/
void examine_from(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
{
+ wcsession *WCC = WC;
+
+ CheckConvertBufs(WCC);
FreeStrBuf(&Msg->from);
Msg->from = NewStrBufPlain(NULL, StrLength(HdrLine));
- StrBuf_RFC822_to_Utf8(Msg->from, HdrLine, WC->DefaultCharset, FoundCharset);
+ StrBuf_RFC822_2_Utf8(Msg->from,
+ HdrLine,
+ WCC->DefaultCharset,
+ FoundCharset,
+ WCC->ConvertBuf1,
+ WCC->ConvertBuf2);
}
void tmplput_MAIL_SUMM_FROM(StrBuf *Target, WCTemplputParams *TP)
{
void examine_subj(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
{
+ wcsession *WCC = WC;
+
+ CheckConvertBufs(WCC);
FreeStrBuf(&Msg->subj);
Msg->subj = NewStrBufPlain(NULL, StrLength(HdrLine));
- StrBuf_RFC822_to_Utf8(Msg->subj, HdrLine, WC->DefaultCharset, FoundCharset);
+ StrBuf_RFC822_2_Utf8(Msg->subj,
+ HdrLine,
+ WCC->DefaultCharset,
+ FoundCharset,
+ WCC->ConvertBuf1,
+ WCC->ConvertBuf2);
}
void tmplput_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP)
{
void examine_msgn(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
{
+ wcsession *WCC = WC;
+
+ CheckConvertBufs(WCC);
FreeStrBuf(&Msg->reply_inreplyto);
Msg->reply_inreplyto = NewStrBufPlain(NULL, StrLength(HdrLine));
- StrBuf_RFC822_to_Utf8(Msg->reply_inreplyto, HdrLine, WC->DefaultCharset, FoundCharset);
+ StrBuf_RFC822_2_Utf8(Msg->reply_inreplyto,
+ HdrLine,
+ WCC->DefaultCharset,
+ FoundCharset,
+ WCC->ConvertBuf1,
+ WCC->ConvertBuf2);
}
void tmplput_MAIL_SUMM_INREPLYTO(StrBuf *Target, WCTemplputParams *TP)
{
void examine_wefw(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
{
+ wcsession *WCC = WC;
+
+ CheckConvertBufs(WCC);
FreeStrBuf(&Msg->reply_references);
Msg->reply_references = NewStrBufPlain(NULL, StrLength(HdrLine));
- StrBuf_RFC822_to_Utf8(Msg->reply_references, HdrLine, WC->DefaultCharset, FoundCharset);
+ StrBuf_RFC822_2_Utf8(Msg->reply_references,
+ HdrLine,
+ WCC->DefaultCharset,
+ FoundCharset,
+ WCC->ConvertBuf1,
+ WCC->ConvertBuf2);
}
void tmplput_MAIL_SUMM_REFIDS(StrBuf *Target, WCTemplputParams *TP)
{
void examine_cccc(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
{
+ wcsession *WCC = WC;
+
+ CheckConvertBufs(WCC);
FreeStrBuf(&Msg->cccc);
Msg->cccc = NewStrBufPlain(NULL, StrLength(HdrLine));
- StrBuf_RFC822_to_Utf8(Msg->cccc, HdrLine, WC->DefaultCharset, FoundCharset);
+ StrBuf_RFC822_2_Utf8(Msg->cccc,
+ HdrLine,
+ WCC->DefaultCharset,
+ FoundCharset,
+ WCC->ConvertBuf1,
+ WCC->ConvertBuf2);
if (Msg->AllRcpt == NULL)
Msg->AllRcpt = NewStrBufPlain(NULL, StrLength(HdrLine));
if (StrLength(Msg->AllRcpt) > 0) {
void examine_rcpt(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
{
+ wcsession *WCC = WC;
+
+ CheckConvertBufs(WCC);
FreeStrBuf(&Msg->to);
Msg->to = NewStrBufPlain(NULL, StrLength(HdrLine));
- StrBuf_RFC822_to_Utf8(Msg->to, HdrLine, WC->DefaultCharset, FoundCharset);
+ StrBuf_RFC822_2_Utf8(Msg->to,
+ HdrLine,
+ WCC->DefaultCharset,
+ FoundCharset,
+ WCC->ConvertBuf1,
+ WCC->ConvertBuf2);
if (Msg->AllRcpt == NULL)
Msg->AllRcpt = NewStrBufPlain(NULL, StrLength(HdrLine));
if (StrLength(Msg->AllRcpt) > 0) {
const char *Ptr = NULL;
wc_mime_attachment *Mime;
StrBuf *Buf;
-
+ wcsession *WCC = WC;
+
+ CheckConvertBufs(WCC);
Mime = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
memset(Mime, 0, sizeof(wc_mime_attachment));
Mime->msgnum = Msg->msgnum;
Mime->Name = NewStrBuf();
StrBufExtract_NextToken(Buf, HdrLine, &Ptr, '|');
- StrBuf_RFC822_to_Utf8(Mime->Name, Buf, WC->DefaultCharset, FoundCharset);
+ StrBuf_RFC822_2_Utf8(Mime->Name,
+ Buf,
+ WCC->DefaultCharset,
+ FoundCharset,
+ WCC->ConvertBuf1,
+ WCC->ConvertBuf2);
StrBufTrim(Mime->Name);
StrBufExtract_NextToken(Buf, HdrLine, &Ptr, '|');
Mime->FileName = NewStrBuf();
- StrBuf_RFC822_to_Utf8(Mime->FileName, Buf, WC->DefaultCharset, FoundCharset);
+ StrBuf_RFC822_2_Utf8(Mime->FileName,
+ Buf,
+ WCC->DefaultCharset,
+ FoundCharset,
+ WCC->ConvertBuf1,
+ WCC->ConvertBuf2);
StrBufTrim(Mime->FileName);
Mime->PartNum = NewStrBuf();
void examine_hnod(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
{
+ wcsession *WCC = WC;
+
+ CheckConvertBufs(WCC);
FreeStrBuf(&Msg->hnod);
Msg->hnod = NewStrBufPlain(NULL, StrLength(HdrLine));
- StrBuf_RFC822_to_Utf8(Msg->hnod, HdrLine, WC->DefaultCharset, FoundCharset);
+ StrBuf_RFC822_2_Utf8(Msg->hnod,
+ HdrLine,
+ WCC->DefaultCharset,
+ FoundCharset,
+ WCC->ConvertBuf1,
+ WCC->ConvertBuf2);
}
void tmplput_MAIL_SUMM_H_NODE(StrBuf *Target, WCTemplputParams *TP)
{
{
wcsession *WCC = WC;
+ CheckConvertBufs(WCC);
+
Msg->from = NewStrBufPlain(NULL, StrLength(Line));
StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
if (StrLength(ConversionBuffer) != 0) {
/* Handle senders with RFC2047 encoding */
- StrBuf_RFC822_to_Utf8(Msg->from, ConversionBuffer, WCC->DefaultCharset, NULL);
+ StrBuf_RFC822_2_Utf8(Msg->from,
+ ConversionBuffer,
+ WCC->DefaultCharset,
+ NULL,
+ WCC->ConvertBuf1,
+ WCC->ConvertBuf2);
}
/* node name */
if (StrLength(ConversionBuffer) == 0)
StrBufAppendBufPlain(Msg->subj, _("(no subject)"), -1,0);
else {
- StrBuf_RFC822_to_Utf8(Msg->subj, ConversionBuffer, WCC->DefaultCharset, NULL);
+ StrBuf_RFC822_2_Utf8(Msg->subj,
+ ConversionBuffer,
+ WCC->DefaultCharset,
+ NULL,
+ WCC->ConvertBuf1,
+ WCC->ConvertBuf2);
}
return 1;
(wcsession *sess)
{
DeleteHash(&sess->attachments);
+ FreeStrBuf(&sess->ConvertBuf1);
+ FreeStrBuf(&sess->ConvertBuf2);
}