diff --git a/src/porting.cpp b/src/porting.cpp index a5bf5d6..e3e5cc7 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -33,6 +33,7 @@ #include "config.h" #include "debug.h" #include "filesys.h" +#include "player.h" #ifdef __APPLE__ #include "CoreFoundation/CoreFoundation.h" @@ -374,19 +375,20 @@ void initializePaths(char* argv0) std::string getUser() { + std::string user("someone"); #ifdef _WIN32 char buff[1024]; int size = 1024; if (GetUserName(buff,LPDWORD(&size))) - return std::string(buff); + user = std::string(buff); #else char* u = getenv("USER"); if (u) - return std::string(u); + user = std::string(u); #endif - return std::string("someone"); + return string_allowify(user,PLAYERNAME_ALLOWED_CHARS); } } //namespace porting diff --git a/src/utility.h b/src/utility.h index d0cbdf6..3b08f3a 100644 --- a/src/utility.h +++ b/src/utility.h @@ -1413,23 +1413,34 @@ private: */ inline bool string_allowed(const std::string &s, const std::string &allowed_chars) { - for(u32 i=0; i