Skip to content

Commit

Permalink
Remove references to "blacklist".
Browse files Browse the repository at this point in the history
  • Loading branch information
renanferrari committed Mar 5, 2021
1 parent 7a9a227 commit e796f20
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,49 +18,49 @@ public void testEmptyString() {
assertEquals(sourceTest, output);
}

public void testNonBlacklistedUrl1() {
public void testNonDenylistedUrl1() {
String sourceTest = "http://test.com";
String output = AutolinkUtils.autoCreateLinks(sourceTest);
String expected = "<a href=\"http://test.com\">http://test.com</a>";
assertEquals(expected, output);
}

public void testNonBlacklistedUrl2() {
public void testNonDenylistedUrl2() {
String sourceTest = "http://test.com http://test.com";
String output = AutolinkUtils.autoCreateLinks(sourceTest);
String expected =
"<a href=\"http://test.com\">http://test.com</a> <a href=\"http://test.com\">http://test.com</a>";
assertEquals(expected, output);
}

public void testNonBlacklistedUrl3() {
public void testNonDenylistedUrl3() {
String sourceTest = "http://test.com\nhttp://test.com";
String output = AutolinkUtils.autoCreateLinks(sourceTest);
String expected =
"<a href=\"http://test.com\">http://test.com</a>\n<a href=\"http://test.com\">http://test.com</a>";
assertEquals(expected, output);
}

public void testBlacklistedUrl1() {
public void testDenylistedUrl1() {
String sourceTest = "http://youtube.com/watch?test";
String output = AutolinkUtils.autoCreateLinks(sourceTest);
assertEquals(sourceTest, output);
}

public void testBlacklistedUrlIgnoreCase1() {
public void testDenylistedUrlIgnoreCase1() {
String sourceTest = "http://youtube.com/WATCH?test";
String output = AutolinkUtils.autoCreateLinks(sourceTest);
assertEquals(sourceTest, output);
}

public void testBlacklistedUrlKickStarter1() {
public void testDenylistedUrlKickStarter1() {
String sourceTest = "testing https://www.kickstarter.com/projects/583173617/raspi-boy-retro-"
+ "handheld-emulation-console-electro ponies";
String output = AutolinkUtils.autoCreateLinks(sourceTest);
assertEquals(sourceTest, output);
}

public void testBlacklistedUrlKickStarter2() {
public void testDenylistedUrlKickStarter2() {
String sourceTest = "testing http://kck.st/2gNq7KK ponies";
String output = AutolinkUtils.autoCreateLinks(sourceTest);
assertEquals(sourceTest, output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class SiteSettingsModel {
private static final String USER_ACCOUNT_REQUIRED_COLUMN_NAME = "userAccountRequired";
private static final String ALLOWLIST_COLUMN_NAME = "whitelist";
private static final String MODERATION_KEYS_COLUMN_NAME = "moderationKeys";
private static final String BLACKLIST_KEYS_COLUMN_NAME = "blacklistKeys";
private static final String DENYLIST_KEYS_COLUMN_NAME = "blacklistKeys";
private static final String SHARING_LABEL_COLUMN_NAME = "sharingLabel";
private static final String SHARING_BUTTON_STYLE_COLUMN_NAME = "sharingButtonStyle";
private static final String ALLOW_REBLOG_BUTTON_COLUMN_NAME = "allowReblogButton";
Expand Down Expand Up @@ -139,7 +139,7 @@ public class SiteSettingsModel {
+ USER_ACCOUNT_REQUIRED_COLUMN_NAME + " BOOLEAN, "
+ ALLOWLIST_COLUMN_NAME + " BOOLEAN, "
+ MODERATION_KEYS_COLUMN_NAME + " TEXT, "
+ BLACKLIST_KEYS_COLUMN_NAME + " TEXT"
+ DENYLIST_KEYS_COLUMN_NAME + " TEXT"
+ ");";

public boolean isInLocalTable;
Expand Down Expand Up @@ -178,7 +178,7 @@ public class SiteSettingsModel {
public boolean commentAutoApprovalKnownUsers;
public int maxLinks;
public List<String> holdForModeration;
public List<String> blacklist;
public List<String> denylist;
public String sharingLabel;
public String sharingButtonStyle;
public boolean allowReblogButton;
Expand Down Expand Up @@ -242,7 +242,7 @@ && equals(timezone, otherModel.timezone)
&& equals(defaultPostFormat, otherModel.defaultPostFormat)
&& holdForModeration != null
&& holdForModeration.equals(otherModel.holdForModeration)
&& blacklist != null && blacklist.equals(otherModel.blacklist)
&& denylist != null && denylist.equals(otherModel.denylist)
&& sharingLabel != null && sharingLabel.equals(otherModel.sharingLabel)
&& sharingButtonStyle != null && sharingButtonStyle.equals(otherModel.sharingButtonStyle)
&& allowReblogButton == otherModel.allowReblogButton
Expand Down Expand Up @@ -306,8 +306,8 @@ public void copyFrom(SiteSettingsModel other) {
if (other.holdForModeration != null) {
holdForModeration = new ArrayList<>(other.holdForModeration);
}
if (other.blacklist != null) {
blacklist = new ArrayList<>(other.blacklist);
if (other.denylist != null) {
denylist = new ArrayList<>(other.denylist);
}
if (other.sharingLabel != null) {
sharingLabel = other.sharingLabel;
Expand Down Expand Up @@ -369,14 +369,14 @@ public void deserializeOptionsDatabaseCursor(Cursor cursor, SparseArrayCompat<Ca
jetpackSearchEnabled = getBooleanFromCursor(cursor, JETPACK_SEARCH_ENABLED_COLUMN_NAME);

String moderationKeys = getStringFromCursor(cursor, MODERATION_KEYS_COLUMN_NAME);
String blacklistKeys = getStringFromCursor(cursor, BLACKLIST_KEYS_COLUMN_NAME);
String denylistKeys = getStringFromCursor(cursor, DENYLIST_KEYS_COLUMN_NAME);
holdForModeration = new ArrayList<>();
blacklist = new ArrayList<>();
denylist = new ArrayList<>();
if (!TextUtils.isEmpty(moderationKeys)) {
Collections.addAll(holdForModeration, moderationKeys.split("\n"));
}
if (!TextUtils.isEmpty(blacklistKeys)) {
Collections.addAll(blacklist, blacklistKeys.split("\n"));
if (!TextUtils.isEmpty(denylistKeys)) {
Collections.addAll(denylist, denylistKeys.split("\n"));
}

sharingLabel = getStringFromCursor(cursor, SHARING_LABEL_COLUMN_NAME);
Expand Down Expand Up @@ -466,14 +466,14 @@ public ContentValues serializeToDatabase() {
moderationKeys.append(key).append("\n");
}
}
StringBuilder blacklistKeys = new StringBuilder();
if (blacklist != null) {
for (String key : blacklist) {
blacklistKeys.append(key).append("\n");
StringBuilder denylistKeys = new StringBuilder();
if (denylist != null) {
for (String key : denylist) {
denylistKeys.append(key).append("\n");
}
}
values.put(MODERATION_KEYS_COLUMN_NAME, moderationKeys.toString());
values.put(BLACKLIST_KEYS_COLUMN_NAME, blacklistKeys.toString());
values.put(DENYLIST_KEYS_COLUMN_NAME, denylistKeys.toString());
values.put(SHARING_LABEL_COLUMN_NAME, sharingLabel);
values.put(SHARING_BUTTON_STYLE_COLUMN_NAME, sharingButtonStyle);
values.put(ALLOW_REBLOG_BUTTON_COLUMN_NAME, allowReblogButton);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public class SiteSettingsFragment extends PreferenceFragment
private DetailListPreference mAllowlistPref;
private Preference mMultipleLinksPref;
private Preference mModerationHoldPref;
private Preference mBlacklistPref;
private Preference mDenylistPref;

// Advanced settings
private Preference mStartOverPref;
Expand Down Expand Up @@ -276,7 +276,7 @@ public class SiteSettingsFragment extends PreferenceFragment
// Reference to the state of the fragment
private boolean mIsFragmentPaused = false;

// Hold for Moderation and Blacklist settings
// Hold for Moderation and Denylist settings
private Dialog mDialog;
private ActionMode mActionMode;
private MultiSelectRecyclerViewAdapter mAdapter;
Expand Down Expand Up @@ -557,10 +557,10 @@ public boolean onPreferenceClick(Preference preference) {
mEditingList = mSiteSettings.getModerationKeys();
showListEditorDialog(R.string.site_settings_moderation_hold_title,
R.string.site_settings_hold_for_moderation_description);
} else if (preference == mBlacklistPref) {
mEditingList = mSiteSettings.getBlacklistKeys();
showListEditorDialog(R.string.site_settings_blacklist_title,
R.string.site_settings_blacklist_description);
} else if (preference == mDenylistPref) {
mEditingList = mSiteSettings.getDenylistKeys();
showListEditorDialog(R.string.site_settings_denylist_title,
R.string.site_settings_denylist_description);
} else if (preference == mJpAllowlistPref) {
AnalyticsTracker.track(Stat.SITE_SETTINGS_JETPACK_ALLOWLISTED_IPS_VIEWED);
mEditingList = mSiteSettings.getJetpackAllowlistKeys();
Expand Down Expand Up @@ -738,8 +738,8 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
mRelatedPostsPref.setSummary(newValue.toString());
} else if (preference == mModerationHoldPref) {
mModerationHoldPref.setSummary(mSiteSettings.getModerationHoldDescription());
} else if (preference == mBlacklistPref) {
mBlacklistPref.setSummary(mSiteSettings.getBlacklistDescription());
} else if (preference == mDenylistPref) {
mDenylistPref.setSummary(mSiteSettings.getDenylistDescription());
} else if (preference == mWeekStartPref) {
mSiteSettings.setStartOfWeek(newValue.toString());
mWeekStartPref.setValue(newValue.toString());
Expand Down Expand Up @@ -806,8 +806,8 @@ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, l
public void onDismiss(DialogInterface dialog) {
if (mEditingList == mSiteSettings.getModerationKeys()) {
onPreferenceChange(mModerationHoldPref, mEditingList.size());
} else if (mEditingList == mSiteSettings.getBlacklistKeys()) {
onPreferenceChange(mBlacklistPref, mEditingList.size());
} else if (mEditingList == mSiteSettings.getDenylistKeys()) {
onPreferenceChange(mDenylistPref, mEditingList.size());
} else if (mEditingList == mSiteSettings.getJetpackAllowlistKeys()) {
onPreferenceChange(mJpAllowlistPref, mEditingList.size());
}
Expand Down Expand Up @@ -914,7 +914,7 @@ public void initPreferences() {
mThreadingPref = getClickPref(R.string.pref_key_site_threading);
mMultipleLinksPref = getClickPref(R.string.pref_key_site_multiple_links);
mModerationHoldPref = getClickPref(R.string.pref_key_site_moderation_hold);
mBlacklistPref = getClickPref(R.string.pref_key_site_blacklist);
mDenylistPref = getClickPref(R.string.pref_key_site_denylist);
mStartOverPref = getClickPref(R.string.pref_key_site_start_over);
mExportSitePref = getClickPref(R.string.pref_key_site_export_site);
mDeleteSitePref = getClickPref(R.string.pref_key_site_delete_site);
Expand Down Expand Up @@ -1035,7 +1035,7 @@ public void setEditingEnabled(boolean enabled) {
mAllowCommentsNested, mSendPingbacksPref, mSendPingbacksNested, mReceivePingbacksPref,
mReceivePingbacksNested, mIdentityRequiredPreference, mUserAccountRequiredPref,
mSortByPref, mAllowlistPref, mRelatedPostsPref, mCloseAfterPref, mPagingPref,
mThreadingPref, mMultipleLinksPref, mModerationHoldPref, mBlacklistPref, mWeekStartPref,
mThreadingPref, mMultipleLinksPref, mModerationHoldPref, mDenylistPref, mWeekStartPref,
mDateFormatPref, mTimeFormatPref, mTimezonePref, mPostsPerPagePref, mAmpPref,
mDeleteSitePref, mJpMonitorActivePref, mJpMonitorEmailNotesPref, mJpSsoPref,
mJpMonitorWpNotesPref, mJpBruteForcePref, mJpAllowlistPref, mJpMatchEmailPref, mJpUseTwoFactorPref,
Expand Down Expand Up @@ -1309,7 +1309,7 @@ public void setPreferencesFromSiteSettings() {
mPagingPref.setSummary(mSiteSettings.getPagingDescription());
mRelatedPostsPref.setSummary(mSiteSettings.getRelatedPostsDescription());
mModerationHoldPref.setSummary(mSiteSettings.getModerationHoldDescription());
mBlacklistPref.setSummary(mSiteSettings.getBlacklistDescription());
mDenylistPref.setSummary(mSiteSettings.getDenylistDescription());
mJpMonitorActivePref.setChecked(mSiteSettings.isJetpackMonitorEnabled());
mJpMonitorEmailNotesPref.setChecked(mSiteSettings.shouldSendJetpackMonitorEmailNotifications());
mJpMonitorWpNotesPref.setChecked(mSiteSettings.shouldSendJetpackMonitorWpNotifications());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
* - Comment User Allowlist
* - Comment Link Limit
* - Comment Moderation Hold Filter
* - Comment Blacklist Filter
* - Comment Denylist Filter
* <p>
* This class is marked abstract. This is due to the fact that .org (self-hosted) and .com sites
* expose different API's to query and edit their respective settings (even though the options
Expand Down Expand Up @@ -475,15 +475,15 @@ public int getMultipleLinks() {
return getKeysDescription(getModerationKeys().size());
}

public @NonNull List<String> getBlacklistKeys() {
if (mSettings.blacklist == null) {
mSettings.blacklist = new ArrayList<>();
public @NonNull List<String> getDenylistKeys() {
if (mSettings.denylist == null) {
mSettings.denylist = new ArrayList<>();
}
return mSettings.blacklist;
return mSettings.denylist;
}

public @NonNull String getBlacklistDescription() {
return getKeysDescription(getBlacklistKeys().size());
public @NonNull String getDenylistDescription() {
return getKeysDescription(getDenylistKeys().size());
}

public @NonNull String getJetpackProtectAllowlistSummary() {
Expand Down Expand Up @@ -841,8 +841,8 @@ public void setModerationKeys(List<String> keys) {
mSettings.holdForModeration = keys;
}

public void setBlacklistKeys(List<String> keys) {
mSettings.blacklist = keys;
public void setDenylistKeys(List<String> keys) {
mSettings.denylist = keys;
}

public void setSharingLabel(String sharingLabel) {
Expand Down Expand Up @@ -915,10 +915,10 @@ public boolean moderationHoldListContains(String value) {
}

/**
* Determines if the current Blacklist list contains a given value.
* Determines if the current Denylist list contains a given value.
*/
public boolean blacklistListContains(String value) {
return getBlacklistKeys().contains(value);
public boolean denylistListContains(String value) {
return getDenylistKeys().contains(value);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class WPComSiteSettings extends SiteSettingsInterface {
private static final String ALLOWLIST_KNOWN_USERS_KEY = "comment_whitelist";
private static final String MAX_LINKS_KEY = "comment_max_links";
private static final String MODERATION_KEYS_KEY = "moderation_keys";
private static final String BLACKLIST_KEYS_KEY = "blacklist_keys";
private static final String DENYLIST_KEYS_KEY = "blacklist_keys";
private static final String SHARING_LABEL_KEY = "sharing_label";
private static final String SHARING_BUTTON_STYLE_KEY = "sharing_button_style";
private static final String SHARING_REBLOGS_DISABLED_KEY = "disabled_reblogs";
Expand Down Expand Up @@ -684,7 +684,7 @@ private void deserializeWpComRestResponse(SiteModel site, JSONObject response) {
mRemoteSettings.commentAutoApprovalKnownUsers = settingsObject.optBoolean(ALLOWLIST_KNOWN_USERS_KEY, false);
mRemoteSettings.maxLinks = settingsObject.optInt(MAX_LINKS_KEY, 0);
mRemoteSettings.holdForModeration = new ArrayList<>();
mRemoteSettings.blacklist = new ArrayList<>();
mRemoteSettings.denylist = new ArrayList<>();
mRemoteSettings.sharingLabel = settingsObject.optString(SHARING_LABEL_KEY, "");
mRemoteSettings.sharingButtonStyle = settingsObject.optString(SHARING_BUTTON_STYLE_KEY,
DEFAULT_SHARING_BUTTON_STYLE);
Expand All @@ -709,9 +709,9 @@ private void deserializeWpComRestResponse(SiteModel site, JSONObject response) {
if (modKeys.length() > 0) {
Collections.addAll(mRemoteSettings.holdForModeration, modKeys.split("\n"));
}
String blacklistKeys = settingsObject.optString(BLACKLIST_KEYS_KEY, "");
if (blacklistKeys.length() > 0) {
Collections.addAll(mRemoteSettings.blacklist, blacklistKeys.split("\n"));
String denylistKeys = settingsObject.optString(DENYLIST_KEYS_KEY, "");
if (denylistKeys.length() > 0) {
Collections.addAll(mRemoteSettings.denylist, denylistKeys.split("\n"));
}

if (settingsObject.optString(COMMENT_SORT_ORDER_KEY, "").equals("asc")) {
Expand Down Expand Up @@ -834,16 +834,16 @@ private JSONObject serializeWpComParamsToJSONObject() throws JSONException {
params.put(MODERATION_KEYS_KEY, "");
}
}
if (mSettings.blacklist != null && !mSettings.blacklist.equals(mRemoteSettings.blacklist)) {
if (mSettings.denylist != null && !mSettings.denylist.equals(mRemoteSettings.denylist)) {
StringBuilder builder = new StringBuilder();
for (String key : mSettings.blacklist) {
for (String key : mSettings.denylist) {
builder.append(key);
builder.append("\n");
}
if (builder.length() > 1) {
params.put(BLACKLIST_KEYS_KEY, builder.substring(0, builder.length() - 1));
params.put(DENYLIST_KEYS_KEY, builder.substring(0, builder.length() - 1));
} else {
params.put(BLACKLIST_KEYS_KEY, "");
params.put(DENYLIST_KEYS_KEY, "");
}
}
if (mSettings.sharingLabel != null && !mSettings.sharingLabel.equals(mRemoteSettings.sharingLabel)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ public static String autoCreateLinks(String text) {
while (matcher.find()) {
String whitespaces = matcher.group(1);
String url = matcher.group(2);
boolean blacklisted = false;
// Check if the URL is blacklisted
boolean denylisted = false;
// Check if the URL is denylisted
for (Pattern providerPattern : PROVIDERS) {
Matcher providerMatcher = providerPattern.matcher(url);
if (providerMatcher.matches()) {
blacklisted = true;
denylisted = true;
}
}
// Create a <a href> HTML tag for the link
if (!blacklisted) {
if (!denylisted) {
matcher.appendReplacement(stringBuffer, whitespaces + "<a href=\"" + url + "\">" + url + "</a>");
} else {
matcher.appendReplacement(stringBuffer, whitespaces + url);
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/values/key_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<string name="pref_key_site_allowlist" translatable="false">wp_pref_site_whitelist</string>
<string name="pref_key_site_multiple_links" translatable="false">wp_pref_site_multiple_links</string>
<string name="pref_key_site_moderation_hold" translatable="false">wp_pref_site_moderation_hold</string>
<string name="pref_key_site_blacklist" translatable="false">wp_pref_site_blacklist</string>
<string name="pref_key_site_denylist" translatable="false">wp_pref_site_blacklist</string>
<string name="pref_key_site_advanced" translatable="false">wp_pref_site_advanced</string>
<string name="pref_key_site_disconnect" translatable="false">wp_pref_site_disconnect</string>
<string name="pref_key_site_start_over" translatable="false">wp_pref_site_start_over</string>
Expand Down

0 comments on commit e796f20

Please sign in to comment.