]> jfr.im git - irc/rqf/shadowircd.git/commitdiff
Add channel::only_ascii_channels config option
authorJilles Tjoelker <redacted>
Sat, 21 Feb 2009 23:12:21 +0000 (00:12 +0100)
committerJilles Tjoelker <redacted>
Sat, 21 Feb 2009 23:12:21 +0000 (00:12 +0100)
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.

doc/example.conf
doc/reference.conf
include/s_conf.h
modules/core/m_join.c
modules/m_info.c
src/newconf.c
src/s_conf.c

index ed19682e6b640755c70acd98514e5904c03bd112..042364f36ce9c3fb57385b80f327ad730eef1415 100755 (executable)
@@ -317,6 +317,7 @@ channel {
        no_join_on_split = no;
        burst_topicwho = yes;
        kick_on_split_riding = no;
+       only_ascii_channels = no;
 };
 
 serverhide {
index 716d4f59b8074f07d9875c70ca064b361d1de665..f23050aa7b248ca6e00d82234c80c5d225aac800 100755 (executable)
@@ -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;
 };
 
 
index f9b0ef72fbecbe8e34bd2db545449534faf12df3..31766467f6760d541e58ee4f7da39d3a25cdf17f 100644 (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
index e9f092d2c9cbda24c35495403231f125822c1fcf..f8598d7d10898429c9ef4f4fa98f32b53d7fdf35 100644 (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;
 }
 
index eaf920f07b58c52ed7a4e85912381724961e8c5c..3be948d3bf357e43a0102377bf4295831c907d7c 100644 (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,
index 80c59e8e60e72159fff87bf0970841fdf26c0186..19d6317c4630e2cd8fe86fe460870a51904f9442 100644 (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             },
index 13751b51b5f3f34a08ec77f908022906839ec329..718993fccf38516777843f6b3c79e0078b6716c7 100644 (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;