mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-04-30 01:29:21 +02:00
remove regex aleta sio because of crash bug: https://github.com/otland/forgottenserver/pull/2965
This commit is contained in:
parent
24a3e9b18c
commit
869e101428
@ -392,8 +392,7 @@ void AccessList::parseList(const std::string& list)
|
|||||||
{
|
{
|
||||||
playerList.clear();
|
playerList.clear();
|
||||||
guildList.clear();
|
guildList.clear();
|
||||||
expressionList.clear();
|
allowEveryone = false;
|
||||||
regExList.clear();
|
|
||||||
this->list = list;
|
this->list = list;
|
||||||
if (list.empty()) {
|
if (list.empty()) {
|
||||||
return;
|
return;
|
||||||
@ -402,7 +401,12 @@ void AccessList::parseList(const std::string& list)
|
|||||||
std::istringstream listStream(list);
|
std::istringstream listStream(list);
|
||||||
std::string line;
|
std::string line;
|
||||||
|
|
||||||
|
int lineNo = 1;
|
||||||
while (getline(listStream, line)) {
|
while (getline(listStream, line)) {
|
||||||
|
if (++lineNo > 100) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
trimString(line);
|
trimString(line);
|
||||||
trim_left(line, '\t');
|
trim_left(line, '\t');
|
||||||
trim_right(line, '\t');
|
trim_right(line, '\t');
|
||||||
@ -418,7 +422,7 @@ void AccessList::parseList(const std::string& list)
|
|||||||
if (at_pos != std::string::npos) {
|
if (at_pos != std::string::npos) {
|
||||||
addGuild(line.substr(at_pos + 1));
|
addGuild(line.substr(at_pos + 1));
|
||||||
} else if (line.find("!") != std::string::npos || line.find("*") != std::string::npos || line.find("?") != std::string::npos) {
|
} 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 {
|
} else {
|
||||||
addPlayer(line);
|
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)
|
bool AccessList::isInList(const Player* player)
|
||||||
{
|
{
|
||||||
std::string name = asLowerCaseString(player->getName());
|
if (allowEveryone) {
|
||||||
std::cmatch what;
|
return true;
|
||||||
|
|
||||||
for (const auto& it : regExList) {
|
|
||||||
if (std::regex_match(name.c_str(), what, it.first)) {
|
|
||||||
return it.second;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto playerIt = playerList.find(player->getGUID());
|
auto playerIt = playerList.find(player->getGUID());
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#ifndef FS_HOUSE_H_EB9732E7771A438F9CD0EFA8CB4C58C4
|
#ifndef FS_HOUSE_H_EB9732E7771A438F9CD0EFA8CB4C58C4
|
||||||
#define FS_HOUSE_H_EB9732E7771A438F9CD0EFA8CB4C58C4
|
#define FS_HOUSE_H_EB9732E7771A438F9CD0EFA8CB4C58C4
|
||||||
|
|
||||||
#include <regex>
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "container.h"
|
#include "container.h"
|
||||||
@ -37,7 +36,6 @@ class AccessList
|
|||||||
void parseList(const std::string& list);
|
void parseList(const std::string& list);
|
||||||
void addPlayer(const std::string& name);
|
void addPlayer(const std::string& name);
|
||||||
void addGuild(const std::string& name);
|
void addGuild(const std::string& name);
|
||||||
void addExpression(const std::string& expression);
|
|
||||||
|
|
||||||
bool isInList(const Player* player);
|
bool isInList(const Player* player);
|
||||||
|
|
||||||
@ -47,8 +45,7 @@ class AccessList
|
|||||||
std::string list;
|
std::string list;
|
||||||
std::unordered_set<uint32_t> playerList;
|
std::unordered_set<uint32_t> playerList;
|
||||||
std::unordered_set<uint32_t> guildList; // TODO: include ranks
|
std::unordered_set<uint32_t> guildList; // TODO: include ranks
|
||||||
std::list<std::string> expressionList;
|
bool allowEveryone = false;
|
||||||
std::list<std::pair<std::regex, bool>> regExList;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Door final : public Item
|
class Door final : public Item
|
||||||
|
Loading…
x
Reference in New Issue
Block a user