mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
errbuff fixed, also moved alphanumeric account check to function in StringUtil
This commit is contained in:
parent
9c6b538176
commit
20e80ebb92
@ -384,3 +384,15 @@ std::string EscapeString(const std::string &s) {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool isAlphaNumeric(const char *text)
|
||||
{
|
||||
for (unsigned int charIndex=0; charIndex<strlen(text); charIndex++) {
|
||||
if ((text[charIndex] < 'a' || text[charIndex] > 'z') &&
|
||||
(text[charIndex] < 'A' || text[charIndex] > 'Z') &&
|
||||
(text[charIndex] < '0' || text[charIndex] > '9'))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -51,4 +51,6 @@ char *RemoveApostrophes(const char *s);
|
||||
|
||||
std::vector<std::string> SplitString(const std::string &s, char delim);
|
||||
|
||||
bool isAlphaNumeric(const char *text);
|
||||
|
||||
#endif
|
||||
|
||||
@ -801,18 +801,14 @@ uint32 Database::GetAccountIDByChar(uint32 char_id) {
|
||||
uint32 Database::GetAccountIDByName(const char* accname, int16* status, uint32* lsid) {
|
||||
char *query = nullptr;
|
||||
|
||||
for (unsigned int i=0; i<strlen(accname); i++) {
|
||||
if ((accname[i] < 'a' || accname[i] > 'z') &&
|
||||
(accname[i] < 'A' || accname[i] > 'Z') &&
|
||||
(accname[i] < '0' || accname[i] > '9'))
|
||||
return 0;
|
||||
}
|
||||
if (!isAlphaNumeric(accname))
|
||||
return 0;
|
||||
|
||||
auto results = QueryDatabase(query, MakeAnyLenString(&query, "SELECT id, status, lsaccount_id FROM account WHERE name='%s'", accname));
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in GetAccountIDByAcc query '" << query << "' " << errbuf << std::endl;
|
||||
std::cerr << "Error in GetAccountIDByAcc query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
safe_delete_array(query);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user