Skip to content

Commit

Permalink
fix: valid names in house list (#1738)
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas authored Oct 24, 2023
1 parent 568f40d commit 9d0b803
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
15 changes: 14 additions & 1 deletion src/map/house/house.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,20 @@ bool House::executeTransfer(std::shared_ptr<HouseTransferItem> item, std::shared
}

void AccessList::parseList(const std::string &list) {
std::string validList = validateNameHouse(list);
std::regex regexValidChars("[^a-zA-Z' \n*!@#]+");
std::string validList = std::regex_replace(list, regexValidChars, "");

// Remove empty lines
std::istringstream iss(validList);
std::ostringstream oss;
std::string line;
while (std::getline(iss, line)) {
if (!line.empty()) {
oss << line << '\n';
}
}
validList = oss.str();

playerList.clear();
guildRankList.clear();
allowEveryone = false;
Expand Down
11 changes: 0 additions & 11 deletions src/utils/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1511,17 +1511,6 @@ void consoleHandlerExit() {
return;
}

std::string validateNameHouse(const std::string &list) {
std::string result;
for (char c : list) {
if (isalpha(c) || c == ' ' || c == '\'' || c == '!' || c == '\n'
|| c == '?' || c == '#' || c == '@' || c == '*') {
result += c;
}
}
return result;
}

NameEval_t validateName(const std::string &name) {
StringVector prohibitedWords = { "owner", "gamemaster", "hoster", "admin", "staff", "tibia", "account", "god", "anal", "ass", "fuck", "sex", "hitler", "pussy", "dick", "rape", "cm", "gm", "tutor", "counsellor", "god" };
StringVector toks;
Expand Down
1 change: 0 additions & 1 deletion src/utils/tools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ const char* getReturnMessage(ReturnValue value);
void sleep_for(uint64_t ms);
void capitalizeWords(std::string &source);
void consoleHandlerExit();
std::string validateNameHouse(const std::string &name);
NameEval_t validateName(const std::string &name);

bool isCaskItem(uint16_t itemId);
Expand Down

0 comments on commit 9d0b803

Please sign in to comment.