diff --git a/src/plugins/alias/alias.c b/src/plugins/alias/alias.c index d61cf3646..e70d15b81 100644 --- a/src/plugins/alias/alias.c +++ b/src/plugins/alias/alias.c @@ -603,7 +603,6 @@ alias_config_write_default (void *data, weechat_config_write_line (config_file, "SIGNOFF", "%s", "\"quit\""); weechat_config_write_line (config_file, "T", "%s", "\"topic\""); weechat_config_write_line (config_file, "UB", "%s", "\"unban\""); - weechat_config_write_line (config_file, "UNIG", "%s", "\"unignore\""); weechat_config_write_line (config_file, "W", "%s", "\"who\""); weechat_config_write_line (config_file, "WC", "%s", "\"window merge\""); weechat_config_write_line (config_file, "WI", "%s", "\"whois\""); diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 417554955..2955d199a 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -1309,6 +1309,10 @@ irc_command_halfop (void *data, struct t_gui_buffer *buffer, int argc, void irc_command_ignore_display (struct t_irc_ignore *ignore) { + char *mask; + + mask = weechat_strndup (ignore->mask + 1, strlen (ignore->mask) - 2); + weechat_printf (NULL, _(" %s[%s%d%s]%s mask: %s / server: %s / channel: %s"), IRC_COLOR_CHAT_DELIMITERS, @@ -1316,11 +1320,14 @@ irc_command_ignore_display (struct t_irc_ignore *ignore) ignore->number, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT, - ignore->mask, + (mask) ? mask : ignore->mask, (ignore->server) ? ignore->server : "*", (ignore->channel) ? ignore->channel : "*"); + + if (mask) + free (mask); } /* @@ -3892,7 +3899,8 @@ irc_command_init () " /ignore add toto@domain.com freenode\n" " ignore host \"toto*@*.domain.com\" on freenode/#weechat:\n" " /ignore add toto*@*.domain.com freenode #weechat"), - NULL, &irc_command_ignore, NULL); + "list|add|del %(irc_channel_nicks_hosts) " + "%(irc_servers) %(irc_channels) ", &irc_command_ignore, NULL); weechat_hook_command ("info", N_("get information describing the server"), N_("[target]"), diff --git a/src/plugins/irc/irc-ignore.c b/src/plugins/irc/irc-ignore.c index f4434d3e9..826d282c2 100644 --- a/src/plugins/irc/irc-ignore.c +++ b/src/plugins/irc/irc-ignore.c @@ -117,17 +117,36 @@ irc_ignore_new (const char *mask, const char *server, const char *channel) { struct t_irc_ignore *new_ignore; regex_t *regex; + char *complete_mask; - if (!mask) + if (!mask || !mask[0]) return NULL; + complete_mask = malloc (1 + strlen (mask) + 1 + 1); + if (!complete_mask) + return NULL; + + if (mask[0] == '^') + strcpy (complete_mask, mask); + else + { + strcpy (complete_mask, "^"); + strcat (complete_mask, mask); + } + if (complete_mask[strlen (complete_mask) - 1] != '$') + strcat (complete_mask, "$"); + regex = malloc (sizeof (*regex)); if (!regex) + { + free (complete_mask); return NULL; + } - if (regcomp (regex, mask, REG_NOSUB | REG_ICASE) != 0) + if (regcomp (regex, complete_mask, REG_NOSUB | REG_ICASE) != 0) { free (regex); + free (complete_mask); return NULL; } @@ -135,7 +154,7 @@ irc_ignore_new (const char *mask, const char *server, const char *channel) if (new_ignore) { new_ignore->number = (last_irc_ignore) ? last_irc_ignore->number + 1 : 1; - new_ignore->mask = strdup (mask); + new_ignore->mask = strdup (complete_mask); new_ignore->regex_mask = regex; new_ignore->server = (server) ? strdup (server) : strdup ("*"); new_ignore->channel = (channel) ? strdup (channel) : strdup ("*"); @@ -150,6 +169,8 @@ irc_ignore_new (const char *mask, const char *server, const char *channel) new_ignore->next_ignore = NULL; } + free (complete_mask); + return new_ignore; } @@ -193,9 +214,9 @@ irc_ignore_check (struct t_irc_server *server, struct t_irc_channel *channel, if (server_match && channel_match) { - if (nick && (strcmp (ptr_ignore->mask, nick) == 0)) + if (nick && (regexec (ptr_ignore->regex_mask, nick, 0, NULL, 0) == 0)) return 1; - if (host && regexec (ptr_ignore->regex_mask, host, 0, NULL, 0) == 0) + if (host && (regexec (ptr_ignore->regex_mask, host, 0, NULL, 0) == 0)) return 1; } }