From 120df97dc7f30ce81623cc952ba2bd21b86f2425 Mon Sep 17 00:00:00 2001 From: Dave Hibberd Date: Tue, 31 Oct 2023 22:42:23 +0000 Subject: New upstream version 6.0.24.16 --- WebMail.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'WebMail.c') diff --git a/WebMail.c b/WebMail.c index 981a60d..1b4cd33 100644 --- a/WebMail.c +++ b/WebMail.c @@ -1193,6 +1193,10 @@ int ViewWebMailMessage(struct HTTPConnectionInfo * Session, char * Reply, int Nu } } } + + if (DisplayHTML && stristr(Message, "")) + DisplayStyle = "div"; // Use div so HTML and XML are interpreted + return sprintf(Reply, WebMailMsgTemplate, BBSName, User->Call, Msg->number, Msg->number, Key, Msg->number, Key, DownLoad, Key, Key, Key, DisplayStyle, Message, DisplayStyle); } @@ -1232,9 +1236,7 @@ int ViewWebMailMessage(struct HTTPConnectionInfo * Session, char * Reply, int Nu size_t origlen = msgLen + 1; UCHAR * BufferB = malloc(2 * origlen); - #ifdef WIN32 - WCHAR * BufferW = malloc(2 * origlen); int wlen; int len = (int)origlen; @@ -1246,10 +1248,10 @@ int ViewWebMailMessage(struct HTTPConnectionInfo * Session, char * Reply, int Nu Save = MsgBytes = BufferB; free(BufferW); msgLen = len - 1; // exclude NULL - #else size_t left = 2 * msgLen; - size_t len = msgLen; + size_t outbuflen = left; + size_t len = msgLen + 1; // include null int ret; UCHAR * BufferBP = BufferB; char * orig = MsgBytes; @@ -1270,15 +1272,18 @@ int ViewWebMailMessage(struct HTTPConnectionInfo * Session, char * Reply, int Nu iconv(icu, NULL, NULL, NULL, NULL); // Reset State Machine ret = iconv(icu, &MsgBytes, &len, (char ** __restrict__)&BufferBP, &left); } + + // left is next location to write, so length written is outbuflen - left + // add a null in case iconv didn't complete comversion + + BufferB[outbuflen - left] = 0; + free(Save); Save = MsgBytes = BufferB; msgLen = strlen(MsgBytes); - #endif - } - // ptr += sprintf(ptr, "%s", MsgBytes); memcpy(ptr, MsgBytes, msgLen); @@ -1307,13 +1312,10 @@ int ViewWebMailMessage(struct HTTPConnectionInfo * Session, char * Reply, int Nu ptr += sprintf(ptr, "File for Message %d not found\r", Number); } - if (DisplayHTML && stristr(Message, "html>")) + if (DisplayHTML && stristr(Message, "")) DisplayStyle = "div"; // Use div so HTML and XML are interpreted - - - return sprintf(Reply, WebMailMsgTemplate, BBSName, User->Call, Msg->number, Msg->number, Key, Msg->number, Key, DownLoad, Key, Key, Key, DisplayStyle, Message, DisplayStyle); } -- cgit v1.2.3