Added some username checks, now usernames get stripped,

and only-spaces names are invaliAdded some username checks, now
usernames get stripped, and only-spaces names are invalidd
This commit is contained in:
Isaac Clerencia Perez 2004-07-27 12:51:32 +00:00
parent cd5a5162b7
commit 35500b6027

View file

@ -190,9 +190,11 @@ void server::run()
}
//check the username is valid (all alpha-numeric or space)
const std::string& username = (*login)["username"];
if(std::count_if(username.begin(),username.end(),isalnum) + std::count(username.begin(),username.end(),' ')
!= username.size() || username.empty()) {
std::string username = (*login)["username"];
config::strip(username);
const int alnum = std::count_if(username.begin(),username.end(),isalnum);
const int spaces = std::count(username.begin(),username.end(),' ');
if((alnum + spaces != username.size()) || spaces == username.size() || username.empty()) {
network::send_data(construct_error(
"This username is not valid"),sock);
continue;