Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix the checking of flags values in the settings tab
Changes:
- Accept setting an empty flags-type value in the settings tab
  if the variable specification permits it
- Don't accept substrings of flag values
  E.g. with values: 'one,two,three', 'hree', 'w', etc. used to
  be accepted. Not any more
- Don't accept flags with random pattern-matching special characters
  E.g. with values: 'one,two,three', 'on.', '(o)[n]e*' etc. used
  to be accepted. Not any more.
  • Loading branch information
Rogier-5 authored and paramat committed Jan 10, 2016
1 parent 58babf8 commit 31ac53d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions builtin/mainmenu/tab_settings.lua
Expand Up @@ -506,8 +506,8 @@ local function handle_change_setting_buttons(this, fields)
local new_value = fields["te_setting_value"]
for _,value in ipairs(new_value:split(",", true)) do
value = value:trim()
if not value:match(CHAR_CLASSES.FLAGS .. "+")
or not setting.possible:match("[,]?" .. value .. "[,]?") then
local possible = "," .. setting.possible .. ","
if not possible:find("," .. value .. ",", 0, true) then
this.data.error_message = fgettext_ne("\"$1\" is not a valid flag.", value)
this.data.entered_text = fields["te_setting_value"]
core.update_formspec(this:get_formspec())
Expand Down

0 comments on commit 31ac53d

Please sign in to comment.