X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_who.cpp;h=aa19efe97db3f156ce432fa394750e3911c03818;hb=e2b0f3dc9ef4d56c71d7abda13e6139ca092e387;hp=f32ef77b39fc812ee6fc0515c905c1ef880d1fdf;hpb=dfb1e0da7823641ad648f9fbd19b43d2e6b0d7ad;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_who.cpp b/src/coremods/core_who.cpp index f32ef77b3..aa19efe97 100644 --- a/src/coremods/core_who.cpp +++ b/src/coremods/core_who.cpp @@ -1,10 +1,16 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2018 Peter Powell - * Copyright (C) 2014 Adam + * Copyright (C) 2019 linuxdaemon + * Copyright (C) 2018 Adam + * Copyright (C) 2017-2019, 2021 Sadie Powell + * Copyright (C) 2013-2014, 2016 Attila Molnar + * Copyright (C) 2012, 2019 Robby * Copyright (C) 2009-2010 Daniel De Graaf - * Copyright (C) 2007-2008 Robin Burchell + * Copyright (C) 2009 John Brooks + * Copyright (C) 2008 Robin Burchell + * Copyright (C) 2007 Dennis Friis + * Copyright (C) 2006-2008, 2010 Craig Edwards * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -39,12 +45,29 @@ static const char who_field_order[] = "cuhsnf"; struct WhoData : public Who::Request { - std::string query_flag_order; - - bool GetFlagIndex(char flag, size_t& out) const CXX11_OVERRIDE + bool GetFieldIndex(char flag, size_t& out) const CXX11_OVERRIDE { - out = query_flag_order.find(flag); - return out != std::string::npos; + if (!whox) + { + const char* pos = strchr(who_field_order, flag); + if (pos == NULL) + return false; + + out = pos - who_field_order; + return true; + } + + if (!whox_fields[flag]) + return false; + + out = 0; + for (const char* c = whox_field_order; *c && *c != flag; ++c) + { + if (whox_fields[*c]) + ++out; + } + + return whox_field_order[out]; } WhoData(const CommandBase::Params& parameters) @@ -54,9 +77,6 @@ struct WhoData : public Who::Request if (matchtext == "0") matchtext = "*"; - // Fuzzy matches are when the source has not specified a specific user. - fuzzy_match = (parameters.size() > 1) || (matchtext.find_first_of("*?.") != std::string::npos); - // If flags have been specified by the source. if (parameters.size() > 1) { @@ -86,16 +106,8 @@ struct WhoData : public Who::Request } } - if (whox) - { - for (const char *c = whox_field_order; c; c++) - { - if (whox_fields[*c]) - query_flag_order.push_back(*c); - } - } - else - query_flag_order = who_field_order; + // Fuzzy matches are when the source has not specified a specific user. + fuzzy_match = flags.any() || (matchtext.find_first_of("*?.") != std::string::npos); } }; @@ -379,13 +391,14 @@ void CommandWho::WhoChannel(LocalUser* source, const std::vector& p template void CommandWho::WhoUsers(LocalUser* source, const std::vector& parameters, const T& users, WhoData& data) { + bool source_has_users_auspex = source->HasPrivPermission("users/auspex"); for (typename T::const_iterator iter = users.begin(); iter != users.end(); ++iter) { User* user = GetUser(iter); // Only show users in response to a fuzzy WHO if we can see them normally. bool can_see_normally = user == source || source->SharesChannelWith(user) || !user->IsModeSet(invisiblemode); - if (data.fuzzy_match && !can_see_normally && !source->HasPrivPermission("users/auspex")) + if (data.fuzzy_match && !can_see_normally && !source_has_users_auspex) continue; // Skip the user if it doesn't match the query.