]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix some bugs in LIST constraint parsing.
authorPeter Powell <petpow@saberuk.com>
Thu, 18 Apr 2019 19:34:16 +0000 (20:34 +0100)
committerPeter Powell <petpow@saberuk.com>
Thu, 18 Apr 2019 20:18:16 +0000 (21:18 +0100)
1. Allow flags to be specified in lower case. This behaviour is
   required by the draft-hardy-irc-isupport-00 specification.
2. Allow more than one constraint to be specified.

src/coremods/core_list.cpp

index f03fbbe5e811aae441c2efb899cacd511de1b858..40a5c8b59ddac9977dd35e17a74294a88baa0a7f 100644 (file)
@@ -48,6 +48,7 @@ class CommandList : public Command
                , secretmode(creator, "secret")
                , privatemode(creator, "private")
        {
+               allow_empty_last_param = false;
                Penalty = 5;
        }
 
@@ -87,36 +88,37 @@ CmdResult CommandList::Handle(User* user, const Params& parameters)
        size_t minusers = 0;
        size_t maxusers = 0;
 
-       if ((parameters.size() == 1) && (!parameters[0].empty()))
+       for (Params::const_iterator iter = parameters.begin(); iter != parameters.end(); ++iter)
        {
-               if (parameters[0][0] == '<')
+               const std::string& constraint = *iter;
+               if (constraint[0] == '<')
                {
-                       maxusers = ConvToNum<size_t>(parameters[0].c_str() + 1);
+                       maxusers = ConvToNum<size_t>(constraint.c_str() + 1);
                }
-               else if (parameters[0][0] == '>')
+               else if (constraint[0] == '>')
                {
-                       minusers = ConvToNum<size_t>(parameters[0].c_str() + 1);
+                       minusers = ConvToNum<size_t>(constraint.c_str() + 1);
                }
-               else if (!parameters[0].compare(0, 2, "C<", 2))
+               else if (!constraint.compare(0, 2, "C<", 2) || !constraint.compare(0, 2, "c<", 2))
                {
-                       mincreationtime = ParseMinutes(parameters[0]);
+                       mincreationtime = ParseMinutes(constraint);
                }
-               else if (!parameters[0].compare(0, 2, "C>", 2))
+               else if (!constraint.compare(0, 2, "C>", 2) || !constraint.compare(0, 2, "c>", 2))
                {
-                       maxcreationtime = ParseMinutes(parameters[0]);
+                       maxcreationtime = ParseMinutes(constraint);
                }
-               else if (!parameters[0].compare(0, 2, "T<", 2))
+               else if (!constraint.compare(0, 2, "T<", 2) || !constraint.compare(0, 2, "t<", 2))
                {
-                       mintopictime = ParseMinutes(parameters[0]);
+                       mintopictime = ParseMinutes(constraint);
                }
-               else if (!parameters[0].compare(0, 2, "T>", 2))
+               else if (!constraint.compare(0, 2, "T>", 2) || !constraint.compare(0, 2, "t>", 2))
                {
-                       maxtopictime = ParseMinutes(parameters[0]);
+                       maxtopictime = ParseMinutes(constraint);
                }
                else
                {
                        // If the glob is prefixed with ! it is inverted.
-                       match = parameters[0].c_str();
+                       match = constraint.c_str();
                        if (match[0] == '!')
                        {
                                match_inverted = true;