From 14482679ce9a6afa29bdab4d98c4ee3ac52c51f0 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Wed, 13 Jan 2016 17:03:40 -0600 Subject: [PATCH] ircd: channel: implement an option to strip color codes from channel topics --- doc/ircd.conf.example | 1 + doc/reference.conf | 3 +++ include/s_conf.h | 1 + ircd/channel.c | 4 ++++ ircd/newconf.c | 1 + 5 files changed, 10 insertions(+) diff --git a/doc/ircd.conf.example b/doc/ircd.conf.example index 2a45554f0..5f03d4d31 100755 --- a/doc/ircd.conf.example +++ b/doc/ircd.conf.example @@ -367,6 +367,7 @@ channel { disable_local_channels = no; autochanmodes = "+nt"; displayed_usercount = 3; + strip_topic_colors = no; }; serverhide { diff --git a/doc/reference.conf b/doc/reference.conf index 82f42b942..c4457a9d7 100755 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -822,6 +822,9 @@ channel { * such as LIST >0. */ displayed_usercount = 3; + + /* strip_topic_colors: whether or not color codes in TOPIC should be stripped. */ + strip_topic_colors = no; }; diff --git a/include/s_conf.h b/include/s_conf.h index 3e71f7153..fa490b6e5 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -263,6 +263,7 @@ struct config_channel_entry int disable_local_channels; unsigned int autochanmodes; int displayed_usercount; + int strip_topic_colors; }; struct config_server_hide diff --git a/ircd/channel.c b/ircd/channel.c index 9bc684b4a..6caf9fcb2 100644 --- a/ircd/channel.c +++ b/ircd/channel.c @@ -43,6 +43,7 @@ #include "logger.h" #include "ipv4_from_ipv6.h" #include "s_assert.h" +#include "inline/stringops.h" struct config_channel_entry ConfigChannel; rb_dlink_list global_channel_list; @@ -1158,6 +1159,9 @@ set_channel_topic(struct Channel *chptr, const char *topic, const char *topic_in rb_strlcpy(chptr->topic, topic, TOPICLEN + 1); rb_strlcpy(chptr->topic_info, topic_info, USERHOST_REPLYLEN); chptr->topic_time = topicts; + + if (ConfigChannel.strip_topic_colors) + strip_colour(chptr->topic); } else { diff --git a/ircd/newconf.c b/ircd/newconf.c index 15f106739..19b9d24d5 100644 --- a/ircd/newconf.c +++ b/ircd/newconf.c @@ -2456,6 +2456,7 @@ static struct ConfEntry conf_channel_table[] = { "disable_local_channels", CF_YESNO, NULL, 0, &ConfigChannel.disable_local_channels }, { "autochanmodes", CF_QSTRING, conf_set_channel_autochanmodes, 0, NULL }, { "displayed_usercount", CF_INT, NULL, 0, &ConfigChannel.displayed_usercount }, + { "strip_topic_colors", CF_YESNO, NULL, 0, &ConfigChannel.strip_topic_colors }, { "\0", 0, NULL, 0, NULL } };