aboutsummaryrefslogtreecommitdiffstats
path: root/src/coremods
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-01-24 21:49:28 +0000
committerGravatar Sadie Powell2022-01-24 21:49:28 +0000
commitdc87f6ec299826cd5c3eaf759c8a6c280e486f4b (patch)
treea3e8c3a94699e5514cc2e6c0c5b563192daac618 /src/coremods
parentAdd the new coremods target as a dependency for the all target. (diff)
parentWork around the deprecation of manual DH params in OpenSSL 3.0.0. (diff)
Merge branch 'insp3' into master.
Diffstat (limited to 'src/coremods')
-rw-r--r--src/coremods/core_list.cpp92
1 files changed, 43 insertions, 49 deletions
diff --git a/src/coremods/core_list.cpp b/src/coremods/core_list.cpp
index bbe9effbc..c68132abd 100644
--- a/src/coremods/core_list.cpp
+++ b/src/coremods/core_list.cpp
@@ -71,10 +71,10 @@ CmdResult CommandList::Handle(User* user, const Params& parameters)
time_t maxcreationtime = 0;
// M: Searching based on mask.
+ std::string match;
+
// N: Searching based on !mask.
- bool match_name_topic = false;
- bool match_inverted = false;
- const char* match = NULL;
+ std::string notmatch;
// T: Searching based on topic time, via the "T<val" and "T>val" modifiers to
// search for a topic time that is lower or higher than val respectively.
@@ -87,45 +87,45 @@ CmdResult CommandList::Handle(User* user, const Params& parameters)
size_t minusers = 0;
size_t maxusers = 0;
- for (const auto& constraint : parameters)
+ if (!parameters.empty())
{
- if (constraint[0] == '<')
- {
- maxusers = ConvToNum<size_t>(constraint.c_str() + 1);
- }
- else if (constraint[0] == '>')
- {
- minusers = ConvToNum<size_t>(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))
+ irc::commasepstream constraints(parameters[0]);
+ for (std::string constraint; constraints.GetToken(constraint); )
{
- 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<size_t>(constraint.c_str() + 1);
+ }
+ else if (constraint[0] == '>')
+ {
+ minusers = ConvToNum<size_t>(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 (constraint[0] == '!')
+ {
+ // Ensure that the user didn't just run "LIST !".
+ if (constraint.length() > 2)
+ notmatch = constraint.substr(1);
+ }
+ else
+ {
+ match = constraint;
}
-
- // Ensure that the user didn't just run "LIST !".
- if (match[0])
- match_name_topic = true;
}
}
@@ -151,18 +151,12 @@ CmdResult CommandList::Handle(User* user, const Params& parameters)
continue;
// Attempt to match a glob pattern.
- if (match_name_topic)
- {
- bool matches = InspIRCd::Match(chan->name, match) || InspIRCd::Match(chan->topic, match);
-
- // The user specified an match that we did not match.
- if (!matches && !match_inverted)
- continue;
+ if (!match.empty() && !InspIRCd::Match(chan->name, match) && !InspIRCd::Match(chan->topic, match))
+ continue;
- // The user specified an inverted match that we did match.
- if (matches && match_inverted)
- continue;
- }
+ // Attempt to match an inverted glob pattern.
+ if (!notmatch.empty() && (InspIRCd::Match(chan->name, notmatch) || InspIRCd::Match(chan->topic, notmatch)))
+ continue;
// if the channel is not private/secret, OR the user is on the channel anyway
bool n = (has_privs || chan->HasUser(user));