1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-29 06:16:40 +02:00

irc: fix crash in split of IRC message containing a newline if the server is not given

This commit is contained in:
Sébastien Helleu
2024-05-25 19:28:49 +02:00
parent 6b1d55203b
commit f968bb9c91
3 changed files with 19 additions and 2 deletions
@@ -1997,6 +1997,21 @@ TEST(IrcMessage, Split)
hashtable_remove (server->cap_list, "batch");
hashtable_remove (server->cap_list, "draft/multiline");
/* PRIVMSG with newlines but no server: BATCH is not used */
hashtable = irc_message_split (NULL, "PRIVMSG #channel :test\n\nline 3");
CHECK(hashtable);
LONGS_EQUAL(7, hashtable->items_count);
STRCMP_EQUAL("3", (const char *)hashtable_get (hashtable, "count"));
STRCMP_EQUAL("PRIVMSG #channel :test",
(const char *)hashtable_get (hashtable, "msg1"));
STRCMP_EQUAL("test", (const char *)hashtable_get (hashtable, "args1"));
STRCMP_EQUAL("PRIVMSG #channel :",
(const char *)hashtable_get (hashtable, "msg2"));
STRCMP_EQUAL("", (const char *)hashtable_get (hashtable, "args2"));
STRCMP_EQUAL("PRIVMSG #channel :line 3",
(const char *)hashtable_get (hashtable, "msg3"));
STRCMP_EQUAL("line 3", (const char *)hashtable_get (hashtable, "args3"));
/* 005: no split */
hashtable = irc_message_split (server, "005 nick " MSG_005);
CHECK(hashtable);