diff options
-rw-r--r-- | ChangeLog.adoc | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 18 | ||||
-rw-r--r-- | tests/unit/plugins/irc/test-irc-protocol.cpp | 43 |
3 files changed, 43 insertions, 19 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 9992c784c..4b1261b72 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -55,6 +55,7 @@ Bug fixes:: * buflist: do not display keys added in default context on first load * fset: remove scroll to top of fset buffer when options are added or removed (issue #1892) * irc: fix join of channels in "autojoin" server option on first connection to server if auto reconnection is performed (issue #1873) + * irc: fix target buffer for commands 432/433 (erroneous nickname/nickname already in use) when the nickname looks like a channel * spell: check buffer pointer received in info "spell_dict" * typing: fix crash when pointer buffer is not received in callback for signal "input_text_changed" (issue #1869) diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index e9e430cf4..6ce3e7629 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -1395,7 +1395,9 @@ IRC_PROTOCOL_CALLBACK(generic_error) if (params[arg_error + 1]) { - if (irc_channel_is_channel (server, params[arg_error])) + if ((strcmp (command, "432") != 0) + && (strcmp (command, "433") != 0) + && irc_channel_is_channel (server, params[arg_error])) { pos_channel = params[arg_error]; ptr_channel = irc_channel_search (server, pos_channel); @@ -6519,8 +6521,11 @@ IRC_PROTOCOL_CALLBACK(368) /* * Callback for the IRC command "432": erroneous nickname. * - * Command looks like: - * 432 * mynick :Erroneous Nickname + * Command looks like (not connected to server): + * 432 * nick :Erroneous Nickname + * + * Command looks like (connected to server): + * 432 mynick nick :Erroneous Nickname */ IRC_PROTOCOL_CALLBACK(432) @@ -6568,8 +6573,11 @@ IRC_PROTOCOL_CALLBACK(432) /* * Callback for the IRC command "433": nickname already in use. * - * Command looks like: - * 433 * mynick :Nickname is already in use. + * Command looks like (not connected to server): + * 433 * nick :Nickname is already in use. + * + * Command looks like (connected to server): + * 433 mynick nick :Nickname is already in use. */ IRC_PROTOCOL_CALLBACK(433) diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp index d3c3efe6e..ad83803ae 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -3865,7 +3865,7 @@ TEST(IrcProtocolWithServer, 432_not_connected) TEST(IrcProtocolWithServer, 432_connected) { - SRV_INIT; + SRV_INIT_JOIN; /* not enough parameters */ RECV(":server 432"); @@ -3873,12 +3873,19 @@ TEST(IrcProtocolWithServer, 432_connected) RECV(":server 432 alice"); CHECK_ERROR_PARAMS("432", 1, 2); - RECV(":server 432 * alice"); - CHECK_SRV("-- * alice"); - RECV(":server 432 * alice error"); - CHECK_SRV("-- * alice error"); - RECV(":server 432 * alice :Erroneous Nickname"); - CHECK_SRV("-- * alice Erroneous Nickname"); + RECV(":server 432 alice test%+"); + CHECK_SRV("-- test%+"); + RECV(":server 432 alice test%+ error"); + CHECK_SRV("-- test%+: error"); + RECV(":server 432 alice test%+ :Erroneous Nickname"); + CHECK_SRV("-- test%+: Erroneous Nickname"); + + /* + * special case: erroneous nick is a channel: check that the message is + * still displayed on the server buffer + */ + RECV(":server 432 alice #test :Erroneous Nickname"); + CHECK_SRV("-- #test: Erroneous Nickname"); } /* @@ -3908,7 +3915,7 @@ TEST(IrcProtocolWithServer, 433_not_connected) TEST(IrcProtocolWithServer, 433_connected) { - SRV_INIT; + SRV_INIT_JOIN; /* not enough parameters */ RECV(":server 433"); @@ -3916,12 +3923,20 @@ TEST(IrcProtocolWithServer, 433_connected) RECV(":server 433 alice"); CHECK_ERROR_PARAMS("433", 1, 2); - RECV(":server 433 * alice"); - CHECK_SRV("-- * alice"); - RECV(":server 433 * alice error"); - CHECK_SRV("-- * alice error"); - RECV(":server 433 * alice :Nickname is already in use."); - CHECK_SRV("-- * alice Nickname is already in use."); + RECV(":server 433 alice test"); + CHECK_SRV("-- test"); + RECV(":server 433 alice test error"); + CHECK_SRV("-- test: error"); + RECV(":server 433 alice test :Nickname is already in use."); + CHECK_SRV("-- test: Nickname is already in use."); + + /* + * special case: nickname already used looks like a channel (it should + * never happen in practice): check that the message is still displayed + * on the server buffer + */ + RECV(":server 433 alice #test :Nickname is already in use."); + CHECK_SRV("-- #test: Nickname is already in use."); } /* |