diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 55f0fefd7..b07111936 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -26,7 +26,7 @@ New features:: Bug fixes:: * irc: fix duplicated channels in autojoin option when autojoin_dynamic is enabled (issue #1795) - * irc: fix display of QUIT message with an empty trailing parameter (issue #1797) + * irc: fix display of TOPIC and QUIT messages with an empty trailing parameter (issue #1797) * relay: fix parsing of IRC messages received from clients (issue #1796) [[v3.6]] diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 67941d6bb..6ebd0caf4 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -3258,7 +3258,7 @@ IRC_PROTOCOL_CALLBACK(topic) if (ptr_channel) irc_channel_join_smart_filtered_unmask (ptr_channel, nick); - if (str_topic) + if (str_topic && str_topic[0]) { topic_color = irc_color_decode ( str_topic, @@ -3361,7 +3361,10 @@ IRC_PROTOCOL_CALLBACK(topic) } if (ptr_channel) - irc_channel_set_topic (ptr_channel, str_topic); + { + irc_channel_set_topic (ptr_channel, + (str_topic && str_topic[0]) ? str_topic : NULL); + } if (str_topic) free (str_topic); diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp index 838a0cb8c..9d3c34864 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -1966,6 +1966,11 @@ TEST(IrcProtocolWithServer, topic) CHECK_CHAN("-- alice has unset topic for #test"); POINTERS_EQUAL(NULL, ptr_channel->topic); + /* empty topic (with empty trailing parameter) */ + RECV(":alice!user@host TOPIC #test :"); + CHECK_CHAN("-- alice has unset topic for #test"); + POINTERS_EQUAL(NULL, ptr_channel->topic); + /* new topic */ RECV(":alice!user@host TOPIC #test :new topic "); CHECK_CHAN("-- alice has changed topic for #test to \"new topic \"");