diff --git a/src/house.cpp b/src/house.cpp index 0864b09..244f2a1 100644 --- a/src/house.cpp +++ b/src/house.cpp @@ -392,8 +392,7 @@ void AccessList::parseList(const std::string& list) { playerList.clear(); guildList.clear(); - expressionList.clear(); - regExList.clear(); + allowEveryone = false; this->list = list; if (list.empty()) { return; @@ -402,7 +401,12 @@ void AccessList::parseList(const std::string& list) std::istringstream listStream(list); std::string line; + int lineNo = 1; while (getline(listStream, line)) { + if (++lineNo > 100) { + break; + } + trimString(line); trim_left(line, '\t'); trim_right(line, '\t'); @@ -418,7 +422,7 @@ void AccessList::parseList(const std::string& list) if (at_pos != std::string::npos) { addGuild(line.substr(at_pos + 1)); } else if (line.find("!") != std::string::npos || line.find("*") != std::string::npos || line.find("?") != std::string::npos) { - addExpression(line); + continue; // regexp no longer supported } else { addPlayer(line); } @@ -446,50 +450,10 @@ void AccessList::addGuild(const std::string& name) } } -void AccessList::addExpression(const std::string& expression) -{ - if (std::find(expressionList.begin(), expressionList.end(), expression) != expressionList.end()) { - return; - } - - std::string outExp; - outExp.reserve(expression.length()); - - std::string metachars = ".[{}()\\+|^$"; - for (const char c : expression) { - if (metachars.find(c) != std::string::npos) { - outExp.push_back('\\'); - } - outExp.push_back(c); - } - - replaceString(outExp, "*", ".*"); - replaceString(outExp, "?", ".?"); - - try { - if (!outExp.empty()) { - expressionList.push_back(outExp); - - if (outExp.front() == '!') { - if (outExp.length() > 1) { - regExList.emplace_front(std::regex(outExp.substr(1)), false); - } - } else { - regExList.emplace_back(std::regex(outExp), true); - } - } - } catch (...) {} -} - bool AccessList::isInList(const Player* player) { - std::string name = asLowerCaseString(player->getName()); - std::cmatch what; - - for (const auto& it : regExList) { - if (std::regex_match(name.c_str(), what, it.first)) { - return it.second; - } + if (allowEveryone) { + return true; } auto playerIt = playerList.find(player->getGUID()); diff --git a/src/house.h b/src/house.h index 3d9b543..54fa7df 100644 --- a/src/house.h +++ b/src/house.h @@ -20,7 +20,6 @@ #ifndef FS_HOUSE_H_EB9732E7771A438F9CD0EFA8CB4C58C4 #define FS_HOUSE_H_EB9732E7771A438F9CD0EFA8CB4C58C4 -#include #include #include "container.h" @@ -37,7 +36,6 @@ class AccessList void parseList(const std::string& list); void addPlayer(const std::string& name); void addGuild(const std::string& name); - void addExpression(const std::string& expression); bool isInList(const Player* player); @@ -47,8 +45,7 @@ class AccessList std::string list; std::unordered_set playerList; std::unordered_set guildList; // TODO: include ranks - std::list expressionList; - std::list> regExList; + bool allowEveryone = false; }; class Door final : public Item