mirror of
https://github.com/weechat/weechat.git
synced 2026-06-30 06:46:38 +02:00
irc: fix parsing of MODE command when there are colons after the first mode argument (closes #1296)
This commit is contained in:
@@ -34,6 +34,49 @@
|
||||
#include "irc-modelist.h"
|
||||
|
||||
|
||||
/*
|
||||
* Gets mode arguments: skip colons before arguments.
|
||||
*/
|
||||
|
||||
char *
|
||||
irc_mode_get_arguments (const char *arguments)
|
||||
{
|
||||
char **argv, **argv2, *new_arguments;
|
||||
int argc, i;
|
||||
|
||||
if (!arguments || !arguments[0])
|
||||
return strdup ("");
|
||||
|
||||
argv = weechat_string_split (arguments, " ",
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
|
||||
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
|
||||
0, &argc);
|
||||
if (!argv)
|
||||
return strdup ("");
|
||||
|
||||
argv2 = malloc (sizeof (*argv) * (argc + 1));
|
||||
if (!argv2)
|
||||
{
|
||||
weechat_string_free_split (argv);
|
||||
return strdup ("");;
|
||||
}
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
argv2[i] = (argv[i][0] == ':') ? argv[i] + 1 : argv[i];
|
||||
}
|
||||
argv2[argc] = NULL;
|
||||
|
||||
new_arguments = weechat_string_build_with_split_string (
|
||||
(const char **)argv2, " ");
|
||||
|
||||
weechat_string_free_split (argv);
|
||||
free (argv2);
|
||||
|
||||
return new_arguments;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets type of channel mode, which is a letter from 'A' to 'D':
|
||||
* A = Mode that adds or removes a nick or address to a list. Always has a
|
||||
@@ -397,7 +440,11 @@ irc_mode_channel_set (struct t_irc_server *server,
|
||||
break;
|
||||
}
|
||||
if (ptr_arg)
|
||||
{
|
||||
if (ptr_arg[0] == ':')
|
||||
ptr_arg++;
|
||||
current_arg++;
|
||||
}
|
||||
|
||||
if (smart_filter
|
||||
&& !irc_mode_smart_filtered (server, pos[0]))
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
struct t_irc_server;
|
||||
struct t_irc_channel;
|
||||
|
||||
extern char *irc_mode_get_arguments (const char *arguments);
|
||||
extern char irc_mode_get_chanmode_type (struct t_irc_server *server,
|
||||
char chanmode);
|
||||
extern int irc_mode_channel_set (struct t_irc_server *server,
|
||||
|
||||
@@ -1424,7 +1424,7 @@ IRC_PROTOCOL_CALLBACK(kill)
|
||||
|
||||
IRC_PROTOCOL_CALLBACK(mode)
|
||||
{
|
||||
char *pos_modes, *pos_modes_args;
|
||||
char *pos_modes, *pos_modes_args, *modes_args;
|
||||
int smart_filter, local_mode;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
@@ -1449,6 +1449,7 @@ IRC_PROTOCOL_CALLBACK(mode)
|
||||
local_mode = (irc_server_strcasecmp (server, nick, server->nick) == 0);
|
||||
ptr_nick = irc_nick_search (server, ptr_channel, nick);
|
||||
ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;
|
||||
modes_args = irc_mode_get_arguments (pos_modes_args);
|
||||
weechat_printf_date_tags (
|
||||
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,
|
||||
ptr_buffer),
|
||||
@@ -1464,12 +1465,14 @@ IRC_PROTOCOL_CALLBACK(mode)
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_RESET,
|
||||
pos_modes,
|
||||
(pos_modes_args) ? " " : "",
|
||||
(pos_modes_args) ? pos_modes_args : "",
|
||||
(modes_args && modes_args[0]) ? " " : "",
|
||||
(modes_args && modes_args[0]) ? modes_args : "",
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_RESET,
|
||||
irc_nick_color_for_msg (server, 1, ptr_nick, nick),
|
||||
nick);
|
||||
if (modes_args)
|
||||
free (modes_args);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user