Add channel::only_ascii_channels config option

to restrict channel names to printable ascii only.
Like disable_fake_channels this only applies to joins
by local users; unlike disable_fake_channels it applies
to opers as well.
This commit is contained in:
Jilles Tjoelker 2009-02-22 00:12:21 +01:00
parent 2a003301de
commit dea418e9b4
7 changed files with 29 additions and 4 deletions

View File

@ -317,6 +317,7 @@ channel {
no_join_on_split = no;
burst_topicwho = yes;
kick_on_split_riding = no;
only_ascii_channels = no;
};
serverhide {

View File

@ -733,6 +733,12 @@ channel {
* ratbox-services does.
*/
kick_on_split_riding = no;
/* only ascii channels: disable local users joining channels
* containing characters outside the range 33-126 (non-printable
* or non-ASCII).
*/
only_ascii_channels = no;
};

View File

@ -239,6 +239,7 @@ struct config_channel_entry
int default_split_user_count;
int burst_topicwho;
int kick_on_split_riding;
int only_ascii_channels;
};
struct config_server_hide

View File

@ -990,27 +990,36 @@ do_join_0(struct Client *client_p, struct Client *source_p)
static int
check_channel_name_loc(struct Client *source_p, const char *name)
{
const char *p;
s_assert(name != NULL);
if(EmptyString(name))
return 0;
if(ConfigFileEntry.disable_fake_channels && !IsOper(source_p))
{
for(; *name; ++name)
for(p = name; *p; ++p)
{
if(!IsChanChar(*name) || IsFakeChanChar(*name))
if(!IsChanChar(*p) || IsFakeChanChar(*p))
return 0;
}
}
else
{
for(; *name; ++name)
for(p = name; *p; ++p)
{
if(!IsChanChar(*name))
if(!IsChanChar(*p))
return 0;
}
}
if(ConfigChannel.only_ascii_channels)
{
for(p = name; *p; ++p)
if(*p < 33 || *p > 126)
return 0;
}
return 1;
}

View File

@ -542,6 +542,12 @@ static struct InfoStruct info_table[] = {
&ConfigChannel.no_join_on_split,
"Disallow joining channels when split",
},
{
"only_ascii_channels",
OUTPUT_BOOLEAN_YN,
&ConfigChannel.only_ascii_channels,
"Controls whether non-ASCII is disabled for JOIN"
},
{
"use_except",
OUTPUT_BOOLEAN_YN,

View File

@ -2187,6 +2187,7 @@ static struct ConfEntry conf_channel_table[] =
{ "max_chans_per_user", CF_INT, NULL, 0, &ConfigChannel.max_chans_per_user },
{ "no_create_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_create_on_split },
{ "no_join_on_split", CF_YESNO, NULL, 0, &ConfigChannel.no_join_on_split },
{ "only_ascii_channels", CF_YESNO, NULL, 0, &ConfigChannel.only_ascii_channels },
{ "use_except", CF_YESNO, NULL, 0, &ConfigChannel.use_except },
{ "use_invex", CF_YESNO, NULL, 0, &ConfigChannel.use_invex },
{ "use_knock", CF_YESNO, NULL, 0, &ConfigChannel.use_knock },

View File

@ -811,6 +811,7 @@ set_default_conf(void)
ConfigChannel.max_chans_per_user = 15;
ConfigChannel.max_bans = 25;
ConfigChannel.max_bans_large = 500;
ConfigChannel.only_ascii_channels = NO;
ConfigChannel.burst_topicwho = NO;
ConfigChannel.kick_on_split_riding = NO;