Skip to content

Commit

Permalink
Add modname convention checking
Browse files Browse the repository at this point in the history
Fixes #2037
  • Loading branch information
Ekdohibs committed Feb 18, 2015
1 parent 5a0ed78 commit 804d65a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions builtin/mainmenu/dlg_config_world.lua
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 804d65a

Please sign in to comment.