From b2978c3c4e6b7f00e91d67bdbf7b0ffb6e90a42b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Sat, 29 Nov 2008 08:47:23 +0000 Subject: [PATCH] * br's in quotes so you can write before / after them * parse contenttype header for sub-values like charset. --- webcit/msg_renderers.c | 71 +++++++++++++++++++++---------- webcit/static/t/edit_message.html | 4 ++ 2 files changed, 53 insertions(+), 22 deletions(-) diff --git a/webcit/msg_renderers.c b/webcit/msg_renderers.c index 2f72a5754..a3a7d446c 100644 --- a/webcit/msg_renderers.c +++ b/webcit/msg_renderers.c @@ -464,31 +464,52 @@ void examine_content_lengh(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundC } void examine_content_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) -{////TODO - int len, i; +{ + void *vHdr; + headereval *Hdr; + StrBuf *Token; + StrBuf *Value; + const char* sem; + const char *eq; + int len; + StrBufTrim(HdrLine); Msg->MsgBody->ContentType = NewStrBufDup(HdrLine); - StrBufTrim(Msg->MsgBody->ContentType);/////todo==striplt? - len = StrLength(Msg->MsgBody->ContentType); - for (i=0; iMsgBody->ContentType) + i, "charset=", 8)) {/// TODO: WHUT? -// safestrncpy(mime_charset, &mime_content_type[i+8], - /// sizeof mime_charset); - } - }/**** - for (i=0; iMsgBody->ContentType, len, NULL); + while (sem != NULL) { + while (isspace(*(sem + 1))) + sem ++; + StrBufCutLeft(HdrLine, sem - ChrPtr(HdrLine)); + sem = strchr(ChrPtr(HdrLine), ';'); + if (sem != NULL) + len = sem - ChrPtr(HdrLine); + else + len = StrLength(HdrLine); + FlushStrBuf(Token); + FlushStrBuf(Value); + StrBufAppendBufPlain(Token, ChrPtr(HdrLine), len, 0); + eq = strchr(ChrPtr(Token), '='); + if (eq != NULL) { + len = eq - ChrPtr(Token); + StrBufAppendBufPlain(Value, eq + 1, StrLength(Token) - len - 1, 0); + StrBufCutAt(Token, len, NULL); + StrBufTrim(Value); + } + StrBufTrim(Token); + + if (GetHash(MsgHeaderHandler, SKEY(Token), &vHdr) && + (vHdr != NULL)) { + Hdr = (headereval*)vHdr; + Hdr->evaluator(Msg, Value, FoundCharset); + } + else lprintf(1, "don't know how to handle content type sub-header[%s]\n", ChrPtr(Token)); } } - */ } void tmplput_MAIL_SUMM_N(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) @@ -749,6 +770,11 @@ void tmplput_MIME_ContentType(StrBuf *Target, int nArgs, WCTemplateToken *Tokens StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->ContentType, 0); } +void examine_charset(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) +{ + Msg->MsgBody->Charset = NewStrBufDup(HdrLine); +} + void tmplput_MIME_Charset(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { wc_mime_attachment *mime = (wc_mime_attachment*) Context; @@ -887,4 +913,5 @@ InitModule_MSGRENDERERS RegisterMsgHdr(HKEY("Content-type"), examine_content_type, 0); RegisterMsgHdr(HKEY("Content-length"), examine_content_lengh, 0); RegisterMsgHdr(HKEY("Content-transfer-encoding"), examine_content_encoding, 0); + RegisterMsgHdr(HKEY("charset"), examine_charset, 0); } diff --git a/webcit/static/t/edit_message.html b/webcit/static/t/edit_message.html index 00f809a4b..ca62a1d36 100644 --- a/webcit/static/t/edit_message.html +++ b/webcit/static/t/edit_message.html @@ -85,17 +85,21 @@