add a blacklist of mimetypes which we won't gzip compress on the way out.
[citadel.git] / webcit / messages.c
index 3f8108f0a97c54511b4f97df414caec04346b535..3444d6f9f69512eec49a2411115897679a76c538 100644 (file)
@@ -192,6 +192,9 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, co
        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));
@@ -217,7 +220,6 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, co
                /* Locate a renderer capable of converting this MIME part into HTML */
                if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
                    (vHdr != NULL)) {
-                       WCTemplputParams SubTP;
                        RenderMimeFuncStruct *Render;
                        
                        StackContext(&SuperTP, &SubTP, Msg->MsgBody, CTX_MIME_ATACH, 0, NULL);
@@ -529,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;
 }
@@ -1052,7 +1054,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);
@@ -1126,7 +1128,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);
 
@@ -1163,7 +1165,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);
@@ -1218,16 +1220,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()<br>\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<br>\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<br>\n", WCC->upload_length);
        att = malloc(sizeof(wc_mime_attachment));
        memset(att, 0, sizeof(wc_mime_attachment ));
@@ -1333,10 +1335,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 {
@@ -1452,6 +1455,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);
@@ -1537,7 +1541,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);
@@ -1546,6 +1550,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);
+                               }
                        }
 
 
@@ -1813,9 +1821,11 @@ 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);
+
 
                serv_read_binary(WCC->WBuf, bytes, Buf);
                serv_puts("CLOS");
@@ -1826,9 +1836,11 @@ void mimepart(int force_download)
                        if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) {
                                StrBufExtract_token(Buf, WCC->Hdr->HR.ReqLine, 2, '/');
                                CT = GuessMimeByFilename(SKEY(Buf));
+                               CheckGZipCompressionAllowed (CT, strlen(CT));
                        }
                        if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) {
                                CT = GuessMimeType(SKEY(WCC->WBuf));
+                               CheckGZipCompressionAllowed (CT, strlen(CT));
                        }
                }
                http_transmit_thing(CT, 0);
@@ -2069,6 +2081,7 @@ InitModule_MSG
        l_replyto = FourHash("rep2", 4);
        l_node = FourHash("node", 4);
        l_rfca = FourHash("rfca", 4);
+       l_nvto = FourHash("nvto", 4);
 
        return ;
 }