X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fmessages.c;h=9e538d234a64e106a857606ce5c3fac602f3b6c4;hb=7d548835437de5f5ea26884af56982cb1c8af673;hp=88404111839f02762a9c6c85536aac0eb097d604;hpb=7974c7b863e396a87e1479525a10db9b9cf93ca9;p=citadel.git diff --git a/webcit/messages.c b/webcit/messages.c index 884041118..9e538d234 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -188,9 +188,13 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, co void *vHdr; long len; const char *Key; + WCTemplputParams SuperTP; WCTemplputParams SubTP; StrBuf *Error = NULL; + memset(&SuperTP, 0, sizeof(WCTemplputParams)); + memset(&SubTP, 0, sizeof(WCTemplputParams)); + Buf = NewStrBuf(); FoundCharset = NewStrBuf(); Msg = (message_summary *)malloc(sizeof(message_summary)); @@ -211,38 +215,46 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, co StrBufTrim(Buf); StrBufLowerCase(Buf); - /* Locate a renderer capable of converting this MIME part into HTML */ - if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) && - (vHdr != NULL)) { - RenderMimeFuncStruct *Render; - Render = (RenderMimeFuncStruct*)vHdr; - Render->f(Msg->MsgBody, NULL, FoundCharset); - } - - if (StrLength(Msg->reply_references)> 0) { - /* Trim down excessively long lists of thread references. We eliminate the - * second one in the list so that the thread root remains intact. - */ - int rrtok = num_tokens(ChrPtr(Msg->reply_references), '|'); - int rrlen = StrLength(Msg->reply_references); - if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) { - StrBufRemove_token(Msg->reply_references, 1, '|'); + StackContext(NULL, &SuperTP, Msg, CTX_MAILSUM, 0, NULL); + { + /* Locate a renderer capable of converting this MIME part into HTML */ + if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) && + (vHdr != NULL)) { + RenderMimeFuncStruct *Render; + + StackContext(&SuperTP, &SubTP, Msg->MsgBody, CTX_MIME_ATACH, 0, NULL); + { + Render = (RenderMimeFuncStruct*)vHdr; + Render->f(Target, &SubTP, FoundCharset); + } + UnStackContext(&SubTP); + } + + if (StrLength(Msg->reply_references)> 0) { + /* Trim down excessively long lists of thread references. We eliminate the + * second one in the list so that the thread root remains intact. + */ + int rrtok = num_tokens(ChrPtr(Msg->reply_references), '|'); + int rrlen = StrLength(Msg->reply_references); + if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) { + StrBufRemove_token(Msg->reply_references, 1, '|'); + } } - } - /* now check if we need to translate some mimeparts, and remove the duplicate */ - it = GetNewHashPos(Msg->AllAttach, 0); - while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) && - (vMime != NULL)) { - wc_mime_attachment *Mime = (wc_mime_attachment*) vMime; - evaluate_mime_part(Msg, Mime); - } - DeleteHashPos(&it); - StackContext(NULL, &SubTP, Msg, CTX_MAILSUM, 0, NULL); - { - *OutMime = DoTemplate(tmpl, tmpllen, Target, &SubTP); + /* now check if we need to translate some mimeparts, and remove the duplicate */ + it = GetNewHashPos(Msg->AllAttach, 0); + while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) && + (vMime != NULL)) { + StackContext(&SuperTP, &SubTP, vMime, CTX_MIME_ATACH, 0, NULL); + { + evaluate_mime_part(Target, &SubTP); + } + UnStackContext(&SubTP); + } + DeleteHashPos(&it); + *OutMime = DoTemplate(tmpl, tmpllen, Target, &SuperTP); } - UnStackContext(&SubTP); + UnStackContext(&SuperTP); DestroyMessageSummary(Msg); FreeStrBuf(&FoundCharset); @@ -325,7 +337,7 @@ HttpStatus(long CitadelStatus) */ void handle_one_message(void) { - long CitStatus; + long CitStatus = ERROR + NOT_HERE; int CopyMessage = 0; const StrBuf *Destination; void *vLine; @@ -519,7 +531,7 @@ message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSu StrBufCutLeft(Buf, nBuf + 1); Eval->f(Msg, Buf); } - else syslog(1, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf)); + else syslog(LOG_INFO, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf)); } return Msg; } @@ -903,7 +915,9 @@ void post_mime_to_server(void) { } /* Only do multipart/alternative for mailboxes. BBS and Wiki rooms don't need it. */ - if (WC->CurRoom.view == VIEW_MAILBOX) { + if ((WCC->CurRoom.view == VIEW_MAILBOX) || + (WCC->CurRoom.view == VIEW_JSON_LIST)) + { include_text_alt = 1; } @@ -931,12 +945,22 @@ void post_mime_to_server(void) { serv_printf("\n--%s", alt_boundary); } - serv_puts("Content-type: text/html; charset=utf-8"); - serv_puts("Content-Transfer-Encoding: quoted-printable"); - serv_puts(""); - serv_puts("\r\n"); - text_to_server_qp(bstr("msgtext")); /* Transmit message in quoted-printable encoding */ - serv_puts("\r\n"); + if (havebstr("markdown")) + { + serv_puts("Content-type: text/x-markdown; charset=utf-8"); + serv_puts("Content-Transfer-Encoding: quoted-printable"); + serv_puts(""); + text_to_server_qp(bstr("msgtext")); /* Transmit message in quoted-printable encoding */ + } + else + { + serv_puts("Content-type: text/html; charset=utf-8"); + serv_puts("Content-Transfer-Encoding: quoted-printable"); + serv_puts(""); + serv_puts("\r\n"); + text_to_server_qp(bstr("msgtext")); /* Transmit message in quoted-printable encoding */ + serv_puts("\r\n"); + } if (include_text_alt) { serv_printf("--%s--", alt_boundary); @@ -1040,7 +1064,7 @@ void post_message(void) StrBuf_ServGetln(Buf); if (GetServerStatusMsg(Buf, NULL, 1, 2) != 2) { /* You probably don't even have a dumb Drafts folder */ - syslog(9, "%s:%d: server save to drafts error: %s\n", __FILE__, __LINE__, ChrPtr(Buf) + 4); + syslog(LOG_DEBUG, "%s:%d: server save to drafts error: %s\n", __FILE__, __LINE__, ChrPtr(Buf) + 4); AppendImportantMessage(_("Saved to Drafts failed: "), -1); display_enter(); FreeStrBuf(&Buf); @@ -1114,7 +1138,7 @@ void post_message(void) } else { - syslog(9, "%s\n", ChrPtr(CmdBuf)); + syslog(LOG_DEBUG, "%s\n", ChrPtr(CmdBuf)); serv_puts(ChrPtr(CmdBuf)); FreeStrBuf(&CmdBuf); @@ -1129,7 +1153,7 @@ void post_message(void) serv_printf("Cc: %s", ChrPtr(Cc)); serv_printf("Bcc: %s", ChrPtr(Bcc)); } else { - serv_printf("X-Citadel-Room: %s", ChrPtr(WC->CurRoom.name)); + serv_printf("X-Citadel-Room: %s", ChrPtr(WCC->CurRoom.name)); } } post_mime_to_server(); @@ -1151,7 +1175,7 @@ void post_message(void) } dont_post = lbstr("postseq"); } else { - syslog(9, "%s:%d: server post error: %s", __FILE__, __LINE__, ChrPtr(Buf) + 4); + syslog(LOG_DEBUG, "%s:%d: server post error: %s", __FILE__, __LINE__, ChrPtr(Buf) + 4); AppendImportantMessage(ChrPtr(Buf) + 4, StrLength(Buf) - 4); display_enter(); if (saving_to_drafts) gotoroom(WCC->CurRoom.name); @@ -1206,16 +1230,16 @@ void upload_attachment(void) { void *v; wc_mime_attachment *att; - syslog(9, "upload_attachment()\n"); + syslog(LOG_DEBUG, "upload_attachment()\n"); wc_printf("upload_attachment()
\n"); if (WCC->upload_length <= 0) { - syslog(9, "ERROR no attachment was uploaded\n"); + syslog(LOG_DEBUG, "ERROR no attachment was uploaded\n"); wc_printf("ERROR no attachment was uploaded
\n"); return; } - syslog(9, "Client is uploading %d bytes\n", WCC->upload_length); + syslog(LOG_DEBUG, "Client is uploading %d bytes\n", WCC->upload_length); wc_printf("Client is uploading %d bytes
\n", WCC->upload_length); att = malloc(sizeof(wc_mime_attachment)); memset(att, 0, sizeof(wc_mime_attachment )); @@ -1321,10 +1345,11 @@ long l_cccc; long l_replyto; long l_node; long l_rfca; +long l_nvto; const char *ReplyToModeStrings [3] = { "reply", - "replyalle", + "replyall", "forward" }; typedef enum _eReplyToNodes { @@ -1440,6 +1465,7 @@ void display_enter(void) StrBuf *rcpt = NULL; StrBuf *cccc = NULL; StrBuf *replyto = NULL; + StrBuf *nvto = NULL; serv_printf("MSG0 %ld|1", replying_to); StrBuf_ServGetln(Line); @@ -1525,7 +1551,7 @@ void display_enter(void) } else if (which == l_replyto) { replyto = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5); - } + } else if (which == l_rfca) { StrBuf *FlatRFCA; rfca = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5); @@ -1534,6 +1560,10 @@ void display_enter(void) FreeStrBuf(&rfca); rfca = FlatRFCA; } + else if (which == l_nvto) { + nvto = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5); + putbstr("nvto", nvto); + } } @@ -1574,7 +1604,7 @@ void display_enter(void) to_rcpt = from; from = NULL; if ( (StrLength(node) > 0) - && (strcasecmp(ChrPtr(node), ChrPtr(WC->serv_info->serv_nodename))) + && (strcasecmp(ChrPtr(node), ChrPtr(WCC->serv_info->serv_nodename))) ) { StrBufAppendBufPlain(to_rcpt, HKEY(" @ "), 0); StrBufAppendBuf(to_rcpt, node, 0); @@ -1675,7 +1705,10 @@ void display_enter(void) begin_burst(); output_headers(1, 0, 0, 0, 1, 0); - DoTemplate(HKEY("edit_message"), NULL, &NoCtx); + if (WCC->CurRoom.defview == VIEW_WIKIMD) + DoTemplate(HKEY("edit_markdown_epic"), NULL, &NoCtx); + else + DoTemplate(HKEY("edit_message"), NULL, &NoCtx); end_burst(); return; @@ -1783,6 +1816,7 @@ void postpart(StrBuf *partnum, StrBuf *filename, int force_download) */ void mimepart(int force_download) { + int detect_mime = 0; long msgnum; long ErrorDetail; StrBuf *att; @@ -1801,25 +1835,32 @@ void mimepart(int force_download) if (GetServerStatus(Buf, &ErrorDetail) == 2) { StrBufCutLeft(Buf, 4); bytes = StrBufExtract_long(Buf, 0, '|'); - if (!force_download) { - StrBufExtract_token(ContentType, Buf, 3, '|'); + StrBufExtract_token(ContentType, Buf, 3, '|'); + CheckGZipCompressionAllowed (SKEY(ContentType)); + if (force_download) + { + FlushStrBuf(ContentType); + detect_mime = 0; } - - serv_read_binary(WCC->WBuf, bytes, Buf); - serv_puts("CLOS"); - StrBuf_ServGetln(Buf); - CT = ChrPtr(ContentType); - - if (!force_download) { - if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) { + else + { + if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) + { StrBufExtract_token(Buf, WCC->Hdr->HR.ReqLine, 2, '/'); CT = GuessMimeByFilename(SKEY(Buf)); + StrBufPlain(ContentType, CT, -1); } - if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) { - CT = GuessMimeType(SKEY(WCC->WBuf)); + if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) + { + detect_mime = 1; } } - http_transmit_thing(CT, 0); + serv_read_binary_to_http(ContentType, bytes, 0, detect_mime); + + serv_read_binary(WCC->WBuf, bytes, Buf); + serv_puts("CLOS"); + StrBuf_ServGetln(Buf); + CT = ChrPtr(ContentType); } else { StrBufCutLeft(Buf, 4); switch (ErrorDetail) { @@ -1839,7 +1880,12 @@ void mimepart(int force_download) hprintf("HTTP/1.1 500 %s\n", ChrPtr(Buf)); break; } - output_headers(0, 0, 0, 0, 0, 0); + + hprintf("Pragma: no-cache\r\n" + "Cache-Control: no-store\r\n" + "Expires: -1\r\n" + ); + hprintf("Content-Type: text/plain\r\n"); begin_burst(); wc_printf(_("An error occurred while retrieving this part: %s\n"), @@ -2057,6 +2103,7 @@ InitModule_MSG l_replyto = FourHash("rep2", 4); l_node = FourHash("node", 4); l_rfca = FourHash("rfca", 4); + l_nvto = FourHash("nvto", 4); return ; }