diff --git a/ChangeLog.adoc b/ChangeLog.adoc index c6c37a140..7a4e657ff 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -16,6 +16,7 @@ For a list of important changes that require manual actions, please look at rele Bug fixes:: * core: add missing mouse events "alt-ctrl-button2" and "alt-ctrl-button3" + * irc: fix crash in split of IRC message containing a newline if the server is not given * python: fix truncation of unsigned long long integer returned by function string_parse_size * script: always display list of scripts when searching scripts with `/script search` (issue #2077) * tcl: fix truncation of long integer returned by function hdata_long diff --git a/src/plugins/irc/irc-message.c b/src/plugins/irc/irc-message.c index 181483a7b..7559df556 100644 --- a/src/plugins/irc/irc-message.c +++ b/src/plugins/irc/irc-message.c @@ -1683,8 +1683,9 @@ irc_message_split (struct t_irc_server *server, const char *message) } multiline = ( - ((weechat_strcasecmp (command, "privmsg") == 0) - || (weechat_strcasecmp (command, "notice") == 0)) + server + && ((weechat_strcasecmp (command, "privmsg") == 0) + || (weechat_strcasecmp (command, "notice") == 0)) && message && strchr (message, '\n') && (index_args + 1 <= argc - 1) diff --git a/tests/unit/plugins/irc/test-irc-message.cpp b/tests/unit/plugins/irc/test-irc-message.cpp index 538beb551..d3457753a 100644 --- a/tests/unit/plugins/irc/test-irc-message.cpp +++ b/tests/unit/plugins/irc/test-irc-message.cpp @@ -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);