1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Mainmenu: Trim whitespace from player name, address, port

This commit is contained in:
grorp 2025-03-26 13:31:44 -04:00 committed by GitHub
parent 251bf0ec31
commit b99f90ed80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -30,6 +30,7 @@
#include "common/c_converter.h"
#include "gui/guiOpenURL.h"
#include "gettext.h"
#include "util/string.h"
/******************************************************************************/
std::string ModApiMainMenu::getTextData(lua_State *L, const std::string &name)
@ -126,10 +127,13 @@ int ModApiMainMenu::l_start(lua_State *L)
data->simple_singleplayer_mode = getBoolData(L,"singleplayer",valid);
data->do_reconnect = getBoolData(L, "do_reconnect", valid);
if (!data->do_reconnect) {
data->name = getTextData(L,"playername");
data->password = getTextData(L,"password");
data->address = getTextData(L,"address");
data->port = getTextData(L,"port");
// Get rid of trailing whitespace in name (may be added by autocompletion
// on Android, which would then cause SERVER_ACCESSDENIED_WRONG_CHARS_IN_NAME).
data->name = trim(getTextData(L, "playername"));
data->password = getTextData(L, "password");
// There's no reason for these to have leading/trailing whitespace either.
data->address = trim(getTextData(L, "address"));
data->port = trim(getTextData(L, "port"));
const auto val = getTextData(L, "allow_login_or_register");
if (val == "login")