mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Enforce stricter world names using a blacklist
Blacklisted characters are: / \
This commit is contained in:
parent
a0da6bcf43
commit
5dd1d354f8
4 changed files with 35 additions and 1 deletions
|
@ -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();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue