diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2020-06-04 08:05:57 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2020-06-04 08:05:57 +0200 |
commit | 196a4e28aae154bb3763272771e53a08b27ddb7f (patch) | |
tree | a1bdabb2b6e699425b41f272fac75cd71c421a4f /src | |
parent | f41b17563f44dc540d90ae846cc725d482fb4e26 (diff) | |
download | weechat-196a4e28aae154bb3763272771e53a08b27ddb7f.zip |
irc: fix add of ignore with flags in regex, display full ignore mask in list of ignores (closes #1518)
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/irc/irc-command.c | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 8ff1caa0c..6d6d7fda9 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -2215,10 +2215,6 @@ IRC_COMMAND_CALLBACK(halfop) 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"), @@ -2227,12 +2223,9 @@ irc_command_ignore_display (struct t_irc_ignore *ignore) ignore->number, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, - (mask) ? mask : ignore->mask, + ignore->mask, (ignore->server) ? ignore->server : "*", (ignore->channel) ? ignore->channel : "*"); - - if (mask) - free (mask); } /* @@ -2242,7 +2235,7 @@ irc_command_ignore_display (struct t_irc_ignore *ignore) IRC_COMMAND_CALLBACK(ignore) { struct t_irc_ignore *ptr_ignore; - char *mask, *regex, *regex2, *ptr_regex, *server, *channel, *error; + char *mask, *regex, *regex2, *ptr_regex, *pos, *server, *channel, *error; int length; long number; @@ -2295,12 +2288,35 @@ IRC_COMMAND_CALLBACK(ignore) } /* add "^" and "$" around regex */ - length = 1 + strlen (ptr_regex) + 1 + 1; - regex2 = malloc (length); - if (regex2) + if (strncmp (ptr_regex, "(?", 2) == 0) { - snprintf (regex2, length, "^%s$", ptr_regex); - ptr_regex = regex2; + /* add chars after the regex flags */ + pos = strchr (ptr_regex, ')'); + if (pos) + { + length = 1 + strlen (ptr_regex) + 1 + 1; + regex2 = malloc (length); + if (regex2) + { + pos++; + memcpy (regex2, ptr_regex, pos - ptr_regex); + regex2[pos - ptr_regex] = '\0'; + strcat (regex2, "^"); + strcat (regex2, pos); + strcat (regex2, "$"); + ptr_regex = regex2; + } + } + } + else + { + length = 1 + strlen (ptr_regex) + 1 + 1; + regex2 = malloc (length); + if (regex2) + { + snprintf (regex2, length, "^%s$", ptr_regex); + ptr_regex = regex2; + } } if (irc_ignore_search (ptr_regex, server, channel)) @@ -2365,8 +2381,7 @@ IRC_COMMAND_CALLBACK(ignore) ptr_ignore = irc_ignore_search_by_number (number); if (ptr_ignore) { - mask = weechat_strndup (ptr_ignore->mask + 1, - strlen (ptr_ignore->mask) - 2); + mask = strdup (ptr_ignore->mask); irc_ignore_free (ptr_ignore); weechat_printf (NULL, _("%s: ignore \"%s\" deleted"), IRC_PLUGIN_NAME, mask); |