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"); @@ -1037,6 +1035,34 @@ TEST(IrcProtocolWithServer, batch_with_batch_cap) POINTERS_EQUAL(NULL, irc_batch_search (ptr_server, "ref1")); POINTERS_EQUAL(NULL, irc_batch_search (ptr_server, "ref2")); + /* 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"); + 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; @@ -1051,14 +1077,14 @@ TEST(IrcProtocolWithServer, batch_with_batch_cap) /* 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"); + } /*