1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-01 20:26:38 +02:00

Changes to unrl_utf8_make_valid():

1) No longer impose a static maximum length
2) Caller must provide a work buffer and maximum length
3) Add a strict length check option
This commit is contained in:
Bram Matthys
2021-08-09 08:45:05 +02:00
parent 91a3c71d60
commit 4ad7d02ffa
3 changed files with 43 additions and 22 deletions
+3 -1
View File
@@ -239,6 +239,8 @@ void websocket_mdata_free(ModData *m)
*/
int websocket_packet_out(Client *from, Client *to, Client *intended_to, char **msg, int *length)
{
static char utf8buf[510];
if (MyConnect(to) && WSU(to) && WSU(to)->handshake_completed)
{
if (WEBSOCKET_TYPE(to) == WEBSOCKET_TYPE_BINARY)
@@ -246,7 +248,7 @@ int websocket_packet_out(Client *from, Client *to, Client *intended_to, char **m
else if (WEBSOCKET_TYPE(to) == WEBSOCKET_TYPE_TEXT)
{
/* Some more conversions are needed */
char *safe_msg = unrl_utf8_make_valid(*msg);
char *safe_msg = unrl_utf8_make_valid(*msg, utf8buf, sizeof(utf8buf), 1);
*msg = safe_msg;
*length = *msg ? strlen(safe_msg) : 0;
websocket_create_packet(WSOP_TEXT, msg, length);