1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

with 10 char usernames, ban "*234567890" instead of "*12345678*"

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2647 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2002-03-31 12:04:57 +00:00 committed by cras
parent 230735f18b
commit dc4b7456dc

View File

@ -45,6 +45,7 @@ char *ban_get_mask(IRC_CHANNEL_REC *channel, const char *nick, int ban_type)
{
NICK_REC *rec;
char *str, *user, *host;
int size;
g_return_val_if_fail(IS_IRC_CHANNEL(channel), NULL);
g_return_val_if_fail(nick != NULL, NULL);
@ -59,17 +60,18 @@ char *ban_get_mask(IRC_CHANNEL_REC *channel, const char *nick, int ban_type)
/* there's a limit of 10 characters in user mask. so, banning
someone with user mask of 10 characters gives us "*1234567890",
which is one too much.. so, replace the 10th character with '*' */
which is one too much.. so, remove the first character after "*"
so we'll get "*234567890" */
user = strchr(str, '!');
if (user == NULL) return str;
host = strchr(++user, '@');
if (host == NULL) return str;
if ((int) (host-user) >= 10) {
size = (int) (host-user);
if (size >= 10) {
/* too long user mask */
user[9] = '*';
g_memmove(user+10, host, strlen(host)+1);
g_memmove(user+1, user+(size-9), strlen(user+(size-9))+1);
}
return str;
}