X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fserver.cpp;h=217d1501da6b089f867b3e678a5985e635d0d6db;hb=66dbd438f23a6beb06b0d44b9121deeb1e3f73bc;hp=1a92c13a0dbe44eaf6538717ec0290aba0bc894c;hpb=4743b23e5c15cd2a9cb86f857e1b7199533201bb;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/server.cpp b/src/server.cpp index 1a92c13a0..217d1501d 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1,8 +1,15 @@ /* * InspIRCd -- Internet Relay Chat Daemon * + * Copyright (C) 2019 nia + * Copyright (C) 2013-2014, 2016 Attila Molnar + * Copyright (C) 2013, 2016-2017, 2020 Sadie Powell + * Copyright (C) 2013 Adam + * Copyright (C) 2012 Robby + * Copyright (C) 2012 ChrisTX + * Copyright (C) 2009 Uli Schlachter * Copyright (C) 2009 Daniel De Graaf - * Copyright (C) 2008 Craig Edwards + * Copyright (C) 2008, 2010 Craig Edwards * Copyright (C) 2007-2008 Robin Burchell * Copyright (C) 2007 Dennis Friis * @@ -20,9 +27,9 @@ */ -#include -#include "exitcodes.h" #include "inspircd.h" +#include "exitcodes.h" +#include void InspIRCd::SignalHandler(int signal) { @@ -155,6 +162,27 @@ std::string UIDGenerator::GetUID() return current_uid; } +void ISupportManager::AppendValue(std::string& buffer, const std::string& value) +{ + // If this token has no value then we have nothing to do. + if (value.empty()) + return; + + // This function implements value escaping according to the rules of the ISUPPORT draft: + // https://tools.ietf.org/html/draft-brocklesby-irc-isupport-03 + buffer.push_back('='); + for (std::string::const_iterator iter = value.begin(); iter != value.end(); ++iter) + { + // The value must be escaped if: + // (1) It is a banned character in an IRC parameter (NUL, LF, CR, SPACE). + // (2) It has special meaning within an ISUPPORT token (EQUALS, BACKSLASH). + if (*iter == '\0' || *iter == '\n' || *iter == '\r' || *iter == ' ' || *iter == '=' || *iter == '\\') + buffer.append(InspIRCd::Format("\\x%X", *iter)); + else + buffer.push_back(*iter); + } +} + void ISupportManager::Build() { /** @@ -166,19 +194,20 @@ void ISupportManager::Build() tokens["AWAYLEN"] = ConvToStr(ServerInstance->Config->Limits.MaxAway); tokens["CASEMAPPING"] = ServerInstance->Config->CaseMapping; tokens["CHANLIMIT"] = InspIRCd::Format("#:%u", ServerInstance->Config->MaxChans); - tokens["CHANMODES"] = ServerInstance->Modes->GiveModeList(MODETYPE_CHANNEL); tokens["CHANNELLEN"] = ConvToStr(ServerInstance->Config->Limits.ChanMax); tokens["CHANTYPES"] = "#"; - tokens["ELIST"] = "MU"; + tokens["HOSTLEN"] = ConvToStr(ServerInstance->Config->Limits.MaxHost); tokens["KICKLEN"] = ConvToStr(ServerInstance->Config->Limits.MaxKick); + tokens["LINELEN"] = ConvToStr(ServerInstance->Config->Limits.MaxLine); tokens["MAXTARGETS"] = ConvToStr(ServerInstance->Config->MaxTargets); tokens["MODES"] = ConvToStr(ServerInstance->Config->Limits.MaxModes); + tokens["NAMELEN"] = ConvToStr(ServerInstance->Config->Limits.MaxReal); tokens["NETWORK"] = ServerInstance->Config->Network; tokens["NICKLEN"] = ConvToStr(ServerInstance->Config->Limits.NickMax); tokens["PREFIX"] = ServerInstance->Modes->BuildPrefixes(); tokens["STATUSMSG"] = ServerInstance->Modes->BuildPrefixes(false); tokens["TOPICLEN"] = ConvToStr(ServerInstance->Config->Limits.MaxTopic); - tokens["VBANLIST"]; + tokens["USERLEN"] = ConvToStr(ServerInstance->Config->Limits.IdentMax); // Modules can add new tokens and also edit or remove existing tokens FOREACH_MOD(On005Numeric, (tokens)); @@ -200,10 +229,7 @@ void ISupportManager::Build() { numeric.push(it->first); std::string& token = numeric.GetParams().back(); - - // If this token has a value then append a '=' char after the name and then the value itself - if (!it->second.empty()) - token.append(1, '=').append(it->second); + AppendValue(token, it->second); token_count++;