kike: fix wildcard matching
It wasn't IRC case-insensitive.
This commit is contained in:
parent
9b2b3844e2
commit
68303ed788
29
src/kike.c
29
src/kike.c
|
@ -507,6 +507,17 @@ irc_get_text (struct server_context *ctx, int id, const char *def)
|
||||||
return catgets (ctx->catalog, 1, id, def);
|
return catgets (ctx->catalog, 1, id, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
irc_fnmatch (const char *pattern, const char *string)
|
||||||
|
{
|
||||||
|
size_t pattern_size = strlen (pattern) + 1;
|
||||||
|
size_t string_size = strlen (string) + 1;
|
||||||
|
char x_pattern[pattern_size], x_string[string_size];
|
||||||
|
irc_strxfrm (x_pattern, pattern, pattern_size);
|
||||||
|
irc_strxfrm (x_string, string, string_size);
|
||||||
|
return fnmatch (x_pattern, x_string, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// --- Channels ----------------------------------------------------------------
|
// --- Channels ----------------------------------------------------------------
|
||||||
|
|
||||||
static struct channel_user *
|
static struct channel_user *
|
||||||
|
@ -709,20 +720,16 @@ irc_close_link (struct client *c, const char *reason)
|
||||||
static bool
|
static bool
|
||||||
client_in_mask_list (const struct client *c, const struct str_vector *mask)
|
client_in_mask_list (const struct client *c, const struct str_vector *mask)
|
||||||
{
|
{
|
||||||
struct str client;
|
char *client = xstrdup_printf ("%s!%s@%s",
|
||||||
str_init (&client);
|
|
||||||
str_append_printf (&client, "%s!%s@%s",
|
|
||||||
c->nickname, c->username, c->hostname);
|
c->nickname, c->username, c->hostname);
|
||||||
irc_strxfrm (client.str, client.str, client.len);
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
for (size_t i = 0; i < mask->len; i++)
|
for (size_t i = 0; i < mask->len; i++)
|
||||||
// FIXME: irc_strxfrm() for the mask (save in canonical format?)
|
if (!irc_fnmatch (client, mask->vector[i]))
|
||||||
if (!fnmatch (client.str, mask->vector[i], 0))
|
|
||||||
{
|
{
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
str_free (&client);
|
free (client);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1507,10 +1514,10 @@ irc_match_send_rpl_whoreply (struct client *c, struct client *target,
|
||||||
if ((target->mode & IRC_USER_MODE_INVISIBLE) && !is_roommate)
|
if ((target->mode & IRC_USER_MODE_INVISIBLE) && !is_roommate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fnmatch (mask, target->hostname, 0)
|
if (irc_fnmatch (mask, target->hostname)
|
||||||
&& fnmatch (mask, target->nickname, 0)
|
&& irc_fnmatch (mask, target->nickname)
|
||||||
&& fnmatch (mask, target->realname, 0)
|
&& irc_fnmatch (mask, target->realname)
|
||||||
&& fnmatch (mask, c->ctx->server_name, 0))
|
&& irc_fnmatch (mask, c->ctx->server_name))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Try to find a channel they're on that's visible to us
|
// Try to find a channel they're on that's visible to us
|
||||||
|
|
Loading…
Reference in New Issue