diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-05-14 15:28:19 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-05-14 15:33:37 +0200 |
commit | a6b8c95519033e484ce3b0a7c21278d35690403d (patch) | |
tree | a3bf108c507453ad453606b2db6443b3712d9cb4 | |
parent | 060cb48094f6a9d187d4645ecb1ec4cd4f374931 (diff) | |
download | weechat-a6b8c95519033e484ce3b0a7c21278d35690403d.zip |
irc: do not display multiline message if capability "draft/multiline" is not enabled (issue #1923)
-rw-r--r-- | src/plugins/irc/irc-batch.c | 6 | ||||
-rw-r--r-- | tests/unit/plugins/irc/test-irc-protocol.cpp | 38 |
2 files changed, 36 insertions, 8 deletions
diff --git a/src/plugins/irc/irc-batch.c b/src/plugins/irc/irc-batch.c index 87b51b474..9f5bc63c9 100644 --- a/src/plugins/irc/irc-batch.c +++ b/src/plugins/irc/irc-batch.c @@ -496,8 +496,10 @@ irc_batch_modifier_cb (const void *pointer, void *data, if (items && (num_items > 1)) { ptr_server = irc_server_search (items[0]); - if (ptr_server && (num_items > 2) - && (strcmp (items[1], "draft/multiline") == 0)) + if (ptr_server + && (num_items > 2) + && (strcmp (items[1], "draft/multiline") == 0) + && weechat_hashtable_has_key (ptr_server->cap_list, "draft/multiline")) { result = irc_batch_process_multiline (ptr_server, string, items[2]); } diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp index 067e32803..a6a4f1b68 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -918,10 +918,8 @@ TEST(IrcProtocolWithServer, batch_with_batch_cap) SRV_INIT_JOIN2; - /* assume "batch" and "draft/multiline" capabilities are enabled in server */ + /* assume "batch" capability is enabled in server */ hashtable_set (ptr_server->cap_list, "batch", NULL); - hashtable_set (ptr_server->cap_list, "draft/multiline", NULL); - irc_server_buffer_set_input_multiline (ptr_server, 1); /* not enough parameters */ RECV(":server BATCH"); @@ -1045,20 +1043,48 @@ TEST(IrcProtocolWithServer, batch_with_batch_cap) RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :line 2"); CHECK_NO_MSG; RECV(":server BATCH -ref"); + CHECK_CHAN("bob line 1"); + CHECK_CHAN("bob line 2"); + + /* multiline with CTCP */ + RECV(":server BATCH +ref draft/multiline #test"); + CHECK_NO_MSG; + RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :\01ACTION is testing"); + CHECK_NO_MSG; + RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :again\01"); + CHECK_NO_MSG; + RECV(":server BATCH -ref"); + CHECK_CHAN(" * bob is testing"); + CHECK_CHAN("bob again\01"); + RECV(":bob!user_b@host_b PRIVMSG #test :prout\01"); + CHECK_CHAN("bob prout\01"); + + /* assume "draft/multiline" capability is enabled in server */ + hashtable_set (ptr_server->cap_list, "draft/multiline", NULL); + irc_server_buffer_set_input_multiline (ptr_server, 1); + + /* multiline */ + RECV(":server BATCH +ref draft/multiline #test"); + CHECK_NO_MSG; + RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :line 1"); + CHECK_NO_MSG; + RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :line 2"); + CHECK_NO_MSG; + RECV(":server BATCH -ref"); CHECK_CHAN("bob line 1\n" "line 2"); /* multiline with CTCP */ RECV(":server BATCH +ref draft/multiline #test"); CHECK_NO_MSG; - RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :" - "\x01" "ACTION is testing"); + RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :\01ACTION is testing"); CHECK_NO_MSG; - RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :again" "\x01"); + RECV("@batch=ref :bob!user_b@host_b PRIVMSG #test :again\01"); CHECK_NO_MSG; RECV(":server BATCH -ref"); CHECK_CHAN(" * bob is testing\n" "again"); + } /* |