From 44c8d23e9faddacd86671cda9cec69317df1fe5f Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 20 Jan 2022 14:30:48 +0000 Subject: Fix parsing LIST commands with multiple constraints. --- src/coremods/core_list.cpp | 75 ++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/coremods/core_list.cpp b/src/coremods/core_list.cpp index 28ea91ce1..e128a6a17 100644 --- a/src/coremods/core_list.cpp +++ b/src/coremods/core_list.cpp @@ -95,46 +95,49 @@ CmdResult CommandList::Handle(User* user, const Params& parameters) size_t minusers = 0; size_t maxusers = 0; - for (Params::const_iterator iter = parameters.begin(); iter != parameters.end(); ++iter) + if (!parameters.empty()) { - const std::string& constraint = *iter; - if (constraint[0] == '<') + irc::commasepstream constraints(parameters[0]); + for (std::string constraint; constraints.GetToken(constraint); ) { - maxusers = ConvToNum(constraint.c_str() + 1); - } - else if (constraint[0] == '>') - { - minusers = ConvToNum(constraint.c_str() + 1); - } - else if (!constraint.compare(0, 2, "C<", 2) || !constraint.compare(0, 2, "c<", 2)) - { - mincreationtime = ParseMinutes(constraint); - } - else if (!constraint.compare(0, 2, "C>", 2) || !constraint.compare(0, 2, "c>", 2)) - { - maxcreationtime = ParseMinutes(constraint); - } - else if (!constraint.compare(0, 2, "T<", 2) || !constraint.compare(0, 2, "t<", 2)) - { - mintopictime = ParseMinutes(constraint); - } - else if (!constraint.compare(0, 2, "T>", 2) || !constraint.compare(0, 2, "t>", 2)) - { - maxtopictime = ParseMinutes(constraint); - } - else - { - // If the glob is prefixed with ! it is inverted. - match = constraint.c_str(); - if (match[0] == '!') + if (constraint[0] == '<') { - match_inverted = true; - match += 1; + maxusers = ConvToNum(constraint.c_str() + 1); + } + else if (constraint[0] == '>') + { + minusers = ConvToNum(constraint.c_str() + 1); + } + else if (!constraint.compare(0, 2, "C<", 2) || !constraint.compare(0, 2, "c<", 2)) + { + mincreationtime = ParseMinutes(constraint); + } + else if (!constraint.compare(0, 2, "C>", 2) || !constraint.compare(0, 2, "c>", 2)) + { + maxcreationtime = ParseMinutes(constraint); + } + else if (!constraint.compare(0, 2, "T<", 2) || !constraint.compare(0, 2, "t<", 2)) + { + mintopictime = ParseMinutes(constraint); + } + else if (!constraint.compare(0, 2, "T>", 2) || !constraint.compare(0, 2, "t>", 2)) + { + maxtopictime = ParseMinutes(constraint); + } + else + { + // If the glob is prefixed with ! it is inverted. + match = constraint.c_str(); + if (match[0] == '!') + { + match_inverted = true; + match += 1; + } + + // Ensure that the user didn't just run "LIST !". + if (match[0]) + match_name_topic = true; } - - // Ensure that the user didn't just run "LIST !". - if (match[0]) - match_name_topic = true; } } -- cgit v1.3.1-10-gc9f91