diff options
| author | Dave Hibberd <d@vehibberd.com> | 2023-10-31 22:42:23 +0000 |
|---|---|---|
| committer | Dave Hibberd <d@vehibberd.com> | 2023-10-31 22:42:23 +0000 |
| commit | 120df97dc7f30ce81623cc952ba2bd21b86f2425 (patch) | |
| tree | 72bf9b36dac0e78065c082be335dbf357780fb65 /WebMail.c | |
| parent | 7b2a99c53b210949fb2e993e65b6be66a9cbf7a1 (diff) | |
New upstream version 6.0.24.16upstream/6.0.24.16
Diffstat (limited to 'WebMail.c')
| -rw-r--r-- | WebMail.c | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -1193,6 +1193,10 @@ int ViewWebMailMessage(struct HTTPConnectionInfo * Session, char * Reply, int Nu }
}
}
+
+ if (DisplayHTML && stristr(Message, "</html>"))
+ 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, "</html>"))
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);
}
|
