Skip to content

Commit

Permalink
FIX: use allowlist and blocklist terminology (discourse#10209)
Browse files Browse the repository at this point in the history
This is a PR of the renaming whitelist to allowlist and blacklist to the blocklist.
  • Loading branch information
lis2 authored Jul 27, 2020
1 parent 5077cf5 commit e0d9232
Show file tree
Hide file tree
Showing 130 changed files with 676 additions and 570 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ GEM
omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1)
rack
onebox (1.9.30)
onebox (2.0.0)
addressable (~> 2.7.0)
htmlentities (~> 4.3)
multi_json (~> 1.11)
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/admin/components/embeddable-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default Component.extend(bufferedProperty("host"), {

const props = this.buffered.getProperties(
"host",
"path_whitelist",
"allowed_paths",
"class_name"
);
props.category_id = this.categoryId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import discourseComputed from "discourse-common/utils/decorators";
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
/**
A form to create an IP address that will be blocked or whitelisted.
A form to create an IP address that will be blocked or allowed.
Example usage:
{{screened-ip-address-form action=(action "recordAdded")}}
Expand All @@ -21,9 +21,9 @@ export default Component.extend({
formSubmitted: false,
actionName: "block",

@discourseComputed("siteSettings.use_admin_ip_whitelist")
actionNames(adminWhitelistEnabled) {
if (adminWhitelistEnabled) {
@discourseComputed("siteSettings.use_admin_ip_allowlist")
actionNames(adminAllowlistEnabled) {
if (adminAllowlistEnabled) {
return [
{ id: "block", name: I18n.t("admin.logs.screened_ips.actions.block") },
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
{{input value=buffered.class_name placeholder="class" enter=(action "save") class="class-name"}}
</td>
<td class="editing-input">
<div class="label">{{i18n "admin.embedding.path_whitelist"}}</div>
{{input value=buffered.path_whitelist placeholder="/blog/.*" enter=(action "save") class="path-whitelist"}}
<div class="label">{{i18n "admin.embedding.allowed_paths"}}</div>
{{input value=buffered.allowed_paths placeholder="/blog/.*" enter=(action "save") class="path-allowlist"}}
</td>
<td class="editing-input">
<div class="label">{{i18n "admin.embedding.category"}}</div>
Expand All @@ -26,7 +26,7 @@
{{else}}
<td><div class="label">{{i18n "admin.embedding.host"}}</div>{{host.host}}</td>
<td><div class="label">{{i18n "admin.embedding.class_name"}}</div>{{host.class_name}}</td>
<td><div class="label">{{i18n "admin.embedding.path_whitelist"}}</div>{{host.path_whitelist}}</td>
<td><div class="label">{{i18n "admin.embedding.allowed_paths"}}</div>{{host.allowed_paths}}</td>
<td><div class="label">{{i18n "admin.embedding.category"}}</div>{{category-badge host.category}}</td>
<td class="controls">
{{d-button icon="pencil-alt" action=(action "edit")}}
Expand Down
14 changes: 7 additions & 7 deletions app/assets/javascripts/admin/templates/embedding.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<thead>
<th style="width: 25%">{{i18n "admin.embedding.host"}}</th>
<th style="width: 15%">{{i18n "admin.embedding.class_name"}}</th>
<th style="width: 25%">{{i18n "admin.embedding.path_whitelist"}}</th>
<th style="width: 25%">{{i18n "admin.embedding.allowed_paths"}}</th>
<th style="width: 25%">{{i18n "admin.embedding.category"}}</th>
<th style="width: 10%">&nbsp;</th>
</thead>
Expand Down Expand Up @@ -45,16 +45,16 @@
<h3>{{i18n "admin.embedding.crawling_settings"}}</h3>
<p class="description">{{i18n "admin.embedding.crawling_description"}}</p>

{{embedding-setting field="embed_whitelist_selector"
value=embedding.embed_whitelist_selector
{{embedding-setting field="allowed_embed_selectors"
value=embedding.allowed_embed_selectors
placeholder="article, #story, .post"}}

{{embedding-setting field="embed_blacklist_selector"
value=embedding.embed_blacklist_selector
{{embedding-setting field="blocked_embed_selectors"
value=embedding.blocked_embed_selectors
placeholder=".ad-unit, header"}}

{{embedding-setting field="embed_classname_whitelist"
value=embedding.embed_classname_whitelist
{{embedding-setting field="allowed_embed_classnames"
value=embedding.allowed_embed_classnames
placeholder="emoji, classname"}}
</div>

Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/discourse/app/lib/to-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class Tag {
];
}

static whitelists() {
static allowedTags() {
return ["ins", "del", "small", "big", "kbd", "ruby", "rt", "rb", "rp"];
}

Expand Down Expand Up @@ -192,7 +192,7 @@ export class Tag {
};
}

static whitelist(name) {
static allowedTag(name) {
return class extends Tag {
constructor() {
super(name, `<${name}>`, `</${name}>`);
Expand Down Expand Up @@ -526,7 +526,7 @@ function tags() {
...Tag.headings().map((h, i) => Tag.heading(h, i + 1)),
...Tag.slices().map(s => Tag.slice(s, "\n")),
...Tag.emphases().map(e => Tag.emphasis(e[0], e[1])),
...Tag.whitelists().map(t => Tag.whitelist(t)),
...Tag.allowedTags().map(t => Tag.allowedTag(t)),
Tag.aside(),
Tag.cell("td"),
Tag.cell("th"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{/if}}
{{category-selector
categories=model.watchedCategories
blacklist=selectedCategories
blocklist=selectedCategories
onChange=(action (mut model.watchedCategories))
}}
</div>
Expand All @@ -21,7 +21,7 @@
{{/if}}
{{category-selector
categories=model.trackedCategories
blacklist=selectedCategories
blocklist=selectedCategories
onChange=(action (mut model.trackedCategories))
}}
</div>
Expand All @@ -31,7 +31,7 @@
<label>{{d-icon "d-watching-first"}} {{i18n "user.watched_first_post_categories"}}</label>
{{category-selector
categories=model.watchedFirstPostCategories
blacklist=selectedCategories
blocklist=selectedCategories
onChange=(action (mut model.watchedFirstPostCategories))
}}
</div>
Expand All @@ -45,7 +45,7 @@
{{/if}}
{{category-selector
categories=model.mutedCategories
blacklist=selectedCategories
blocklist=selectedCategories
onChange=(action (mut model.mutedCategories))
}}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<label>{{d-icon "d-watching" class="icon watching"}} {{i18n "user.watched_tags"}}</label>
{{tag-chooser
tags=model.watched_tags
blacklist=selectedTags
blocklist=selectedTags
allowCreate=false
everyTag=true
unlimitedTagCount=true
Expand All @@ -19,7 +19,7 @@
<label>{{d-icon "d-tracking" class="icon tracking"}} {{i18n "user.tracked_tags"}}</label>
{{tag-chooser
tags=model.tracked_tags
blacklist=selectedTags
blocklist=selectedTags
allowCreate=false
everyTag=true
unlimitedTagCount=true}}
Expand All @@ -31,7 +31,7 @@
<label>{{d-icon "d-watching-first" class="icon watching-first-post"}} {{i18n "user.watched_first_post_tags"}}</label>
{{tag-chooser
tags=model.watching_first_post_tags
blacklist=selectedTags
blocklist=selectedTags
allowCreate=false
everyTag=true
unlimitedTagCount=true}}
Expand All @@ -45,7 +45,7 @@
<label>{{d-icon "d-muted" class="icon muted"}} {{i18n "user.muted_tags"}}</label>
{{tag-chooser
tags=model.muted_tags
blacklist=selectedTags
blocklist=selectedTags
allowCreate=false
everyTag=true
unlimitedTagCount=true}}
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/discourse/app/widgets/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,12 @@ export default createWidget("header", {
const currentPath = this.register
.lookup("service:router")
.get("_router.currentPath");
const blacklist = [/^discovery\.categories/];
const whitelist = [/^topic\./];
const blocklist = [/^discovery\.categories/];
const allowlist = [/^topic\./];
const check = function(regex) {
return !!currentPath.match(regex);
};
let showSearch = whitelist.any(check) && !blacklist.any(check);
let showSearch = allowlist.any(check) && !blocklist.any(check);

// If we're viewing a topic, only intercept search if there are cloaked posts
if (showSearch && currentPath.match(/^topic\./)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ export function setup(opts, siteSettings, state) {
}

export function cook(raw, opts) {
// we still have to hoist html_raw nodes so they bypass the whitelister
// we still have to hoist html_raw nodes so they bypass the allowlister
// this is the case for oneboxes
let hoisted = {};

Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/pretty-text/addon/oneboxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function resolveSize(img) {

// Detect square images and apply smaller onebox-avatar class
function applySquareGenericOnebox($elem) {
if (!$elem.hasClass("whitelistedgeneric")) {
if (!$elem.hasClass("allowlistedgeneric")) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/pretty-text/addon/white-lister.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default class WhiteLister {
}
}

// Only add to `default` when you always want your whitelist to occur. In other words,
// Only add to `default` when you always want your allowlist to occur. In other words,
// don't change this for a plugin or a feature that can be disabled
export const DEFAULT_LIST = [
"a.attachment",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default MultiSelectComponent.extend({
pluginApiIdentifiers: ["category-selector"],
classNames: ["category-selector"],
categories: null,
blacklist: null,
blockedCategories: null,

selectKitOptions: {
filterable: true,
Expand All @@ -22,14 +22,15 @@ export default MultiSelectComponent.extend({
this._super(...arguments);

if (!this.categories) this.set("categories", []);
if (!this.blacklist) this.set("blacklist", []);
if (!this.blockedCategories) this.set("blockedCategories", []);
},

content: computed("categories.[]", "blacklist.[]", function() {
const blacklist = makeArray(this.blacklist);
content: computed("categories.[]", "blockedCategories.[]", function() {
const blockedCategories = makeArray(this.blockedCategories);
return Category.list().filter(category => {
return (
this.categories.includes(category) || !blacklist.includes(category)
this.categories.includes(category) ||
!blockedCategories.includes(category)
);
});
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default MultiSelectComponent.extend(TagsMixin, {
return "tag-chooser-row";
},

blacklist: null,
blockedTags: null,
attributeBindings: ["categoryId"],
excludeSynonyms: false,
excludeHasSynonyms: false,
Expand Down Expand Up @@ -49,7 +49,7 @@ export default MultiSelectComponent.extend(TagsMixin, {
this._super(...arguments);

this.setProperties({
blacklist: this.blacklist || [],
blockedTags: this.blockedTags || [],
termMatchesForbidden: false,
termMatchErrorMessage: null
});
Expand Down Expand Up @@ -84,9 +84,9 @@ export default MultiSelectComponent.extend(TagsMixin, {
categoryId: this.categoryId
};

if (selectedTags.length || this.blacklist.length) {
if (selectedTags.length || this.blockedTags.length) {
data.selected_tags = selectedTags
.concat(this.blacklist)
.concat(this.blockedTags)
.uniq()
.slice(0, 100);
}
Expand All @@ -106,9 +106,9 @@ export default MultiSelectComponent.extend(TagsMixin, {
termMatchErrorMessage: json.forbidden_message
});

if (context.blacklist) {
if (context.blockedTags) {
results = results.filter(result => {
return !context.blacklist.includes(result.id);
return !context.blockedTags.includes(result.id);
});
}

Expand Down
4 changes: 3 additions & 1 deletion app/assets/stylesheets/common/base/onebox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,8 @@ aside.onebox.stackexchange .onebox-body {
}
}

// whitelistedgeneric twitter labels
// allowlistedgeneric twitter labels
.onebox.allowlistedgeneric,
.onebox.whitelistedgeneric {
.label1,
.label2 {
Expand All @@ -640,6 +641,7 @@ aside.onebox.stackexchange .onebox-body {
}

.onebox {
&.allowlistedgeneric,
&.whitelistedgeneric,
&.gfycat {
.site-icon {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/embeddable_hosts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def destroy

def save_host(host, action)
host.host = params[:embeddable_host][:host]
host.path_whitelist = params[:embeddable_host][:path_whitelist]
host.allowed_paths = params[:embeddable_host][:allowed_paths]
host.class_name = params[:embeddable_host][:class_name]
host.category_id = params[:embeddable_host][:category_id]
host.category_id = SiteSetting.uncategorized_category_id if host.category_id.blank?
Expand Down
14 changes: 7 additions & 7 deletions app/controllers/admin/themes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def preview

def upload_asset

ban_in_whitelist_mode!
ban_in_allowlist_mode!

path = params[:file].path

Expand Down Expand Up @@ -53,7 +53,7 @@ def import
@theme = nil
if params[:theme] && params[:theme].content_type == "application/json"

ban_in_whitelist_mode!
ban_in_allowlist_mode!

# .dcstyle.json import. Deprecated, but still available to allow conversion
json = JSON::parse(params[:theme].read)
Expand Down Expand Up @@ -104,7 +104,7 @@ def import
end
elsif params[:bundle] || (params[:theme] && THEME_CONTENT_TYPES.include?(params[:theme].content_type))

ban_in_whitelist_mode!
ban_in_allowlist_mode!

# params[:bundle] used by theme CLI. params[:theme] used by admin UI
bundle = params[:bundle] || params[:theme]
Expand Down Expand Up @@ -152,7 +152,7 @@ def index

def create

ban_in_whitelist_mode!
ban_in_allowlist_mode!

@theme = Theme.new(name: theme_params[:name],
user_id: theme_user.id,
Expand Down Expand Up @@ -297,8 +297,8 @@ def update_single_setting

private

def ban_in_whitelist_mode!
raise Discourse::InvalidAccess if !GlobalSetting.whitelisted_theme_ids.nil?
def ban_in_allowlist_mode!
raise Discourse::InvalidAccess if !GlobalSetting.allowed_theme_ids.nil?
end

def add_relative_themes!(kind, ids)
Expand Down Expand Up @@ -358,7 +358,7 @@ def theme_params
def set_fields
return unless fields = theme_params[:theme_fields]

ban_in_whitelist_mode!
ban_in_allowlist_mode!

fields.each do |field|
@theme.set_field(
Expand Down
Loading

0 comments on commit e0d9232

Please sign in to comment.