From c0bc5bf7981e30229bdabfdf51a289635fe8be76 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 16 Apr 2022 11:48:08 +0100 Subject: Add ListModeBase::CanonicalizeParam, fix cleaning extban masks. --- include/listmode.h | 17 +++++++++++------ include/modules/extban.h | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/listmode.h b/include/listmode.h index ff28c2196..7e3b49a86 100644 --- a/include/listmode.h +++ b/include/listmode.h @@ -94,10 +94,6 @@ protected: */ unsigned int endoflistnumeric; - /** Automatically tidy up entries - */ - bool tidy; - /** Limits on a per-channel basis read from the \ * config tag. */ @@ -114,9 +110,8 @@ public: * @param modechar Mode character * @param lnum List numeric * @param eolnum End of list numeric - * @param autotidy Automatically tidy list entries on add */ - ListModeBase(Module* Creator, const std::string& Name, char modechar, unsigned int lnum, unsigned int eolnum, bool autotidy); + ListModeBase(Module* Creator, const std::string& Name, char modechar, unsigned int lnum, unsigned int eolnum); /** Determines whether some channels have longer lists than others. */ bool HasVariableLength() const { return chanlimits.size() > 1; } @@ -153,6 +148,16 @@ public: /** @copydoc ModeHandler::OnModeChange */ ModeAction OnModeChange(User* source, User*, Channel* channel, Modes::Change& change) override; + /** Canonicalize the parameter for this list mode. This is only for tweaking + * the parameter locally. You should use ValidateParam to check whether a + * remote-sent parameter is unacceptably malformed without changing it. + * @param user The local user which sent the list mode change. + * @param channel The channel the mode is being changed on. + * @param parameter The parameter that the user specified. + * @return True if the parameter is valid; otherwise, false. + */ + virtual bool CanonicalizeParam(LocalUser* user, Channel* channel, std::string& parameter); + /** Validate parameters. * Overridden by implementing module. * @param user Source user adding the parameter diff --git a/include/modules/extban.h b/include/modules/extban.h index 17c66c031..b90829be9 100644 --- a/include/modules/extban.h +++ b/include/modules/extban.h @@ -73,6 +73,12 @@ public: */ virtual void AddExtBan(Base* extban) = 0; + /** Canonicalises a list mode entry if it is an extban. + * @param text The list mode entry to canonicalize. + * @return True if the text was a valid extban and was canonicalised. Otherwise, false. + */ + virtual bool Canonicalize(std::string& text) const = 0; + /** Unregisters an extban from the manager. * @param extban The extban instance to unregister. */ @@ -151,6 +157,11 @@ protected: } public: + /** Canonicalises a value for this extban. + * @param text The value to canonicalize. + */ + virtual void Canonicalize(std::string& text) { } + /** Retrieves the character used in bans to signify this extban. */ unsigned char GetLetter() const { return letter; } @@ -212,6 +223,13 @@ public: { } + /** @copydoc ExtBan::Base::Canonicalize */ + void Canonicalize(std::string& text) override + { + if (!GetManager() || !GetManager()->Canonicalize(text)) + ModeParser::CleanMask(text); + } + /** @copydoc ExtBan::Base::GetType */ Type GetType() const override { return ExtBan::Type::ACTING; } -- cgit v1.3.1-10-gc9f91