FIX: use allowlist and blocklist terminology (#10209)

This is a PR of the renaming whitelist to allowlist and blacklist to the blocklist.
This commit is contained in:
Krzysztof Kotlarek
2020-07-27 10:23:54 +10:00
committed by GitHub
parent 5077cf52fd
commit e0d9232259
130 changed files with 676 additions and 570 deletions

View File

@ -100,29 +100,29 @@ class SiteSetting < ActiveRecord::Base
WATCHED_SETTINGS ||= [
:default_locale,
:attachment_content_type_blacklist,
:attachment_filename_blacklist,
:unicode_username_character_whitelist,
:blocked_attachment_content_types,
:blocked_attachment_filenames,
:allowed_unicode_username_characters,
:markdown_typographer_quotation_marks
]
def self.reset_cached_settings!
@attachment_content_type_blacklist_regex = nil
@attachment_filename_blacklist_regex = nil
@unicode_username_whitelist_regex = nil
@blocked_attachment_content_types_regex = nil
@blocked_attachment_filenames_regex = nil
@allowed_unicode_username_regex = nil
end
def self.attachment_content_type_blacklist_regex
@attachment_content_type_blacklist_regex ||= Regexp.union(SiteSetting.attachment_content_type_blacklist.split("|"))
def self.blocked_attachment_content_types_regex
@blocked_attachment_content_types_regex ||= Regexp.union(SiteSetting.blocked_attachment_content_types.split("|"))
end
def self.attachment_filename_blacklist_regex
@attachment_filename_blacklist_regex ||= Regexp.union(SiteSetting.attachment_filename_blacklist.split("|"))
def self.blocked_attachment_filenames_regex
@blocked_attachment_filenames_regex ||= Regexp.union(SiteSetting.blocked_attachment_filenames.split("|"))
end
def self.unicode_username_character_whitelist_regex
@unicode_username_whitelist_regex ||= SiteSetting.unicode_username_character_whitelist.present? \
? Regexp.new(SiteSetting.unicode_username_character_whitelist) : nil
def self.allowed_unicode_username_characters_regex
@allowed_unicode_username_regex ||= SiteSetting.allowed_unicode_username_characters.present? \
? Regexp.new(SiteSetting.allowed_unicode_username_characters) : nil
end
# helpers for getting s3 settings that fallback to global
@ -213,6 +213,38 @@ class SiteSetting < ActiveRecord::Base
c.present? && c.to_i != SiteSetting.uncategorized_category_id.to_i
end
ALLOWLIST_DEPRECATED_SITE_SETTINGS = {
'email_domains_blacklist': 'blocked_email_domains',
'email_domains_whitelist': 'allowed_email_domains',
'unicode_username_character_whitelist': 'allowed_unicode_username_characters',
'user_website_domains_whitelist': 'allowed_user_website_domains',
'whitelisted_link_domains': 'allowed_link_domains',
'embed_whitelist_selector': 'allowed_embed_selectors',
'auto_generated_whitelist': 'auto_generated_allowlist',
'attachment_content_type_blacklist': 'blocked_attachment_content_types',
'attachment_filename_blacklist': 'blocked_attachment_filenames',
'use_admin_ip_whitelist': 'use_admin_ip_allowlist',
'blacklist_ip_blocks': 'blocked_ip_blocks',
'whitelist_internal_hosts': 'allowed_internal_hosts',
'whitelisted_crawler_user_agents': 'allowed_crawler_user_agents',
'blacklisted_crawler_user_agents': 'blocked_crawler_user_agents',
'onebox_domains_blacklist': 'blocked_onebox_domains',
'inline_onebox_domains_whitelist': 'allowed_inline_onebox_domains',
'white_listed_spam_host_domains': 'allowed_spam_host_domains',
'embed_blacklist_selector': 'blocked_embed_selectors',
'embed_classname_whitelist': 'allowed_embed_classnames',
}
ALLOWLIST_DEPRECATED_SITE_SETTINGS.each_pair do |old_method, new_method|
self.class.define_method(old_method) do
Discourse.deprecate("#{old_method.to_s} is deprecated, use the #{new_method.to_s}.", drop_from: "2.6")
send(new_method)
end
self.class.define_method("#{old_method}=") do |args|
Discourse.deprecate("#{old_method.to_s} is deprecated, use the #{new_method.to_s}.", drop_from: "2.6")
send("#{new_method}=", args)
end
end
end
# == Schema Information