mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 15:38:27 +00:00
[Loginserver] Code Cleanup and Tweaks (#1653)
* if for whatever reason the world server is not sending an address, use the local address it sends * Log when world is sending loginserver info * Force legacy mode when login host is login.eqemulator.net to avoid misconfigurations at least until things change * Add human IP translation to log messages * Sanitize world server name * Code cleanup and renaming member variables * More cleanup * Remove this-> * Validation constants * Key worldserver lookups by both longname and shortname both * Update allowed character list * Fix short_name API response field; add world_id to response * Shorten receiver verbosity * Remove unnecessary member variables from database and rename database to m_database * Adjust MAX_SERVER_VERSION_LENGTH * Fix indents
This commit is contained in:
@@ -605,3 +605,31 @@ std::string FormatName(const std::string& char_name)
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
|
||||
bool IsAllowedWorldServerCharacterList(char c)
|
||||
{
|
||||
const char *valid_characters = ":[](){}.!@#$%^&*-=+<>/\\|'\"";
|
||||
if (strchr(valid_characters, c)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void SanitizeWorldServerName(char *name)
|
||||
{
|
||||
std::string server_long_name = name;
|
||||
server_long_name.erase(
|
||||
std::remove_if(
|
||||
server_long_name.begin(),
|
||||
server_long_name.end(),
|
||||
[](char c) {
|
||||
return !(std::isalpha(c) || std::isalnum(c) || std::isspace(c) || IsAllowedWorldServerCharacterList(c));
|
||||
}
|
||||
), server_long_name.end()
|
||||
);
|
||||
|
||||
server_long_name = trim(server_long_name);
|
||||
|
||||
strcpy(name, server_long_name.c_str());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user