irc: fix add of ignore with flags in regex, display full ignore mask in list of ignores (closes #1518)

This commit is contained in:
Sébastien Helleu 2020-06-04 08:05:57 +02:00
parent f41b17563f
commit 196a4e28aa
2 changed files with 32 additions and 16 deletions

View File

@ -61,6 +61,7 @@ Bug fixes::
* api: replace plugin and buffer name by buffer pointer in argument "modifier_data" sent to weechat_print modifier callback (issue #42) * api: replace plugin and buffer name by buffer pointer in argument "modifier_data" sent to weechat_print modifier callback (issue #42)
* exec: fix use of same task id for different tasks (issue #1491) * exec: fix use of same task id for different tasks (issue #1491)
* fifo: fix errors when writing in the FIFO pipe (issue #713) * fifo: fix errors when writing in the FIFO pipe (issue #713)
* irc: fix add of ignore with flags in regex, display full ignore mask in list of ignores (issue #1518)
* irc: do not remove spaces at the end of users messages received (issue #1513) * irc: do not remove spaces at the end of users messages received (issue #1513)
* irc: fix realname delimiter color in WHO/WHOX response (issue #1497) * irc: fix realname delimiter color in WHO/WHOX response (issue #1497)
* irc: reuse a buffer with wrong type "channel" when a private message is received (issue #869) * irc: reuse a buffer with wrong type "channel" when a private message is received (issue #869)

View File

@ -2215,10 +2215,6 @@ IRC_COMMAND_CALLBACK(halfop)
void void
irc_command_ignore_display (struct t_irc_ignore *ignore) irc_command_ignore_display (struct t_irc_ignore *ignore)
{ {
char *mask;
mask = weechat_strndup (ignore->mask + 1, strlen (ignore->mask) - 2);
weechat_printf ( weechat_printf (
NULL, NULL,
_(" %s[%s%d%s]%s mask: %s / server: %s / channel: %s"), _(" %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, ignore->number,
IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET, IRC_COLOR_RESET,
(mask) ? mask : ignore->mask, ignore->mask,
(ignore->server) ? ignore->server : "*", (ignore->server) ? ignore->server : "*",
(ignore->channel) ? ignore->channel : "*"); (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) IRC_COMMAND_CALLBACK(ignore)
{ {
struct t_irc_ignore *ptr_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; int length;
long number; long number;
@ -2295,12 +2288,35 @@ IRC_COMMAND_CALLBACK(ignore)
} }
/* add "^" and "$" around regex */ /* add "^" and "$" around regex */
length = 1 + strlen (ptr_regex) + 1 + 1; if (strncmp (ptr_regex, "(?", 2) == 0)
regex2 = malloc (length);
if (regex2)
{ {
snprintf (regex2, length, "^%s$", ptr_regex); /* add chars after the regex flags */
ptr_regex = regex2; 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)) if (irc_ignore_search (ptr_regex, server, channel))
@ -2365,8 +2381,7 @@ IRC_COMMAND_CALLBACK(ignore)
ptr_ignore = irc_ignore_search_by_number (number); ptr_ignore = irc_ignore_search_by_number (number);
if (ptr_ignore) if (ptr_ignore)
{ {
mask = weechat_strndup (ptr_ignore->mask + 1, mask = strdup (ptr_ignore->mask);
strlen (ptr_ignore->mask) - 2);
irc_ignore_free (ptr_ignore); irc_ignore_free (ptr_ignore);
weechat_printf (NULL, _("%s: ignore \"%s\" deleted"), weechat_printf (NULL, _("%s: ignore \"%s\" deleted"),
IRC_PLUGIN_NAME, mask); IRC_PLUGIN_NAME, mask);