diff options
author | Novatux <nathanael.courant@laposte.net> | 2015-02-18 16:48:58 +0100 |
---|---|---|
committer | Novatux <nathanael.courant@laposte.net> | 2015-02-18 17:06:09 +0100 |
commit | b0df67d9c062a08a93d24c304bdbc72b0ced0898 (patch) | |
tree | 440fd362036e988a5a4c4baf447647851474cb20 /builtin/mainmenu/dlg_config_world.lua | |
parent | 45ff8569d7655b480456884745db4a23a07aa722 (diff) | |
download | minetest-b0df67d9c062a08a93d24c304bdbc72b0ced0898.tar.gz minetest-b0df67d9c062a08a93d24c304bdbc72b0ced0898.tar.bz2 minetest-b0df67d9c062a08a93d24c304bdbc72b0ced0898.zip |
Add modname convention checking
Fixes #2037
Diffstat (limited to 'builtin/mainmenu/dlg_config_world.lua')
-rw-r--r-- | builtin/mainmenu/dlg_config_world.lua | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/builtin/mainmenu/dlg_config_world.lua b/builtin/mainmenu/dlg_config_world.lua index a15e4c11f..4d13faea8 100644 --- a/builtin/mainmenu/dlg_config_world.lua +++ b/builtin/mainmenu/dlg_config_world.lua @@ -16,6 +16,9 @@ --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -------------------------------------------------------------------------------- +local function modname_valid(name) + return not name:find("[^a-z0-9_]") +end local function get_formspec(data) @@ -195,10 +198,12 @@ local function handle_buttons(this, fields) for i,mod in ipairs(rawlist) do if not mod.is_modpack and mod.typ ~= "game_mod" then - if mod.enabled then - worldfile:set("load_mod_"..mod.name, "true") + if modname_valid(mod.name) then + worldfile:set("load_mod_"..mod.name, tostring(mod.enabled)) else - worldfile:set("load_mod_"..mod.name, "false") + if mod.enabled then + gamedata.errormessage = fgettext_ne("Failed to enable mod \"$1\" as it contains disallowed characters. Only chararacters [a-z0-9_] are allowed.", mod.name) + end end mods["load_mod_"..mod.name] = nil end |