mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-17 10:25:21 +02:00
Enforce stricter world names using a blacklist
Blacklisted characters are: / \
This commit is contained in:
@@ -39,6 +39,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "tile.h" // getTexturePath
|
||||
#include "filesys.h"
|
||||
#include "util/string.h"
|
||||
#include "subgame.h"
|
||||
|
||||
struct CreateWorldDestMainMenu : public CreateWorldDest
|
||||
{
|
||||
@@ -47,7 +48,10 @@ struct CreateWorldDestMainMenu : public CreateWorldDest
|
||||
{}
|
||||
void accepted(std::wstring name, std::string gameid)
|
||||
{
|
||||
m_menu->createNewWorld(name, gameid);
|
||||
if(!string_allowed_blacklist(wide_to_narrow(name), WORLDNAME_BLACKLISTED_CHARS))
|
||||
m_menu->displayMessageMenu(wgettext("Cannot create world: Name contains invalid characters"));
|
||||
else
|
||||
m_menu->createNewWorld(name, gameid);
|
||||
}
|
||||
GUIMainMenu *m_menu;
|
||||
};
|
||||
@@ -929,3 +933,7 @@ int GUIMainMenu::getTab()
|
||||
return TAB_SINGLEPLAYER; // Default
|
||||
}
|
||||
|
||||
void GUIMainMenu::displayMessageMenu(std::wstring msg)
|
||||
{
|
||||
(new GUIMessageMenu(env, parent, -1, menumgr, msg))->drop();
|
||||
}
|
Reference in New Issue
Block a user