mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 20:31:15 +08:00
DEV: Sanitize integer site settings in front- and back-end (#23816)
Currently, if you set an integer site setting in the admin interface and include thousands separators, you will silently configure the wrong value. This PR replaces TextField inputs for integer site settings with NumberField. It also cleans the numeric input of any non-digits in the backend in case any separators make it through.
This commit is contained in:
@ -31,7 +31,10 @@ class Admin::SiteSettingsController < Admin::AdminController
|
||||
|
||||
raise_access_hidden_setting(id)
|
||||
|
||||
if SiteSetting.type_supervisor.get_type(id) == :uploaded_image_list
|
||||
case SiteSetting.type_supervisor.get_type(id)
|
||||
when :integer
|
||||
value = value.gsub(/\D/, "")
|
||||
when :uploaded_image_list
|
||||
value = Upload.get_from_urls(value.split("|")).to_a
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user