Merge "Clean up disrespectful terms"
diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt
index f02d89a..879ec99 100644
--- a/Documentation/config-gerrit.txt
+++ b/Documentation/config-gerrit.txt
@@ -4423,19 +4423,25 @@
 
 [[receiveemail.filter.mode]]receiveemail.filter.mode::
 +
-A black- and whitelist filter to filter incoming emails.
+An allow and block filter to filter incoming emails.
 +
 If `OFF`, emails are not filtered by the list filter.
 +
-If `WHITELIST`, only emails where a pattern from
+If `ALLOW`, only emails where a pattern from
 <<receiveemail.filter.patterns,receiveemail.filter.patterns>>
 matches 'From' will be processed.
 +
-If `BLACKLIST`, only emails where no pattern from
+If `BLOCK`, only emails where no pattern from
 <<receiveemail.filter.patterns,receiveemail.filter.patterns>>
 matches 'From' will be processed.
 +
 Defaults to `OFF`.
++
+The previous filter-names 'BLACKLIST' and 'WHITELIST' have been deprecated
+since they may be considered disrespectful and there's no technical or
+practical reason to use these exact terms for the filters.
+For backwards compatibility they are still supported but support for these
+deprecated terms will be removed in future releases.
 
 [[receiveemail.filter.patterns]]receiveemail.filter.patterns::
 +
@@ -4566,9 +4572,10 @@
 
 [[sendemail.allowrcpt]]sendemail.allowrcpt::
 +
-If present, each value adds one entry to the whitelist of email
-addresses that Gerrit can send email to.  If set to a complete
-email address, that one address is added to the white list.
+If present, each value adds one entry to the list of allowed email
+addresses that Gerrit can send emails to.  If set to a complete
+email address, that one address is added to the list of allowed
+emails.
 If set to a domain name, any address at that domain can receive
 email from Gerrit.
 +
@@ -4579,9 +4586,10 @@
 
 [[sendemail.denyrcpt]]sendemail.denyrcpt::
 +
-If present, each value adds one entry to the blacklist of email
-addresses that Gerrit can send email to.  If set to a complete
-email address, that one address is added to the blacklist.
+If present, each value adds one entry to the list of email
+addresses that Gerrit can't send emails to.  If set to a complete
+email address, that one address is added to the list of blocked
+emails.
 If set to a domain name, any address at that domain can *not* receive
 email from Gerrit.
 +
diff --git a/java/com/google/gerrit/mail/HtmlParser.java b/java/com/google/gerrit/mail/HtmlParser.java
index 2fc659d..ba73bdd 100644
--- a/java/com/google/gerrit/mail/HtmlParser.java
+++ b/java/com/google/gerrit/mail/HtmlParser.java
@@ -35,7 +35,7 @@
           "gmail_quote" // Used for quoting original content
           );
 
-  private static final ImmutableSet<String> WHITELISTED_HTML_TAGS =
+  private static final ImmutableSet<String> ALLOWED_HTML_TAGS =
       ImmutableSet.of(
           "div", // Most user-typed comments are contained in a <div> tag
           "a", // We allow links to be contained in a comment
@@ -120,8 +120,8 @@
         // There is no user-input in quoted text
         continue;
       }
-      if (!WHITELISTED_HTML_TAGS.contains(elementName)) {
-        // We only accept a set of whitelisted tags that can contain user input
+      if (!ALLOWED_HTML_TAGS.contains(elementName)) {
+        // We only accept a set of allowed tags that can contain user input
         continue;
       }
       if (elementName.equals("a") && e.attr("href").startsWith("mailto:")) {
diff --git a/java/com/google/gerrit/server/mail/ListMailFilter.java b/java/com/google/gerrit/server/mail/ListMailFilter.java
index 23f7e12..67cef45 100644
--- a/java/com/google/gerrit/server/mail/ListMailFilter.java
+++ b/java/com/google/gerrit/server/mail/ListMailFilter.java
@@ -31,8 +31,8 @@
 
   public enum ListFilterMode {
     OFF,
-    WHITELIST,
-    BLACKLIST
+    ALLOW,
+    BLOCK
   }
 
   private final ListFilterMode mode;
@@ -40,12 +40,37 @@
 
   @Inject
   ListMailFilter(@GerritServerConfig Config cfg) {
-    this.mode = cfg.getEnum("receiveemail", "filter", "mode", ListFilterMode.OFF);
+    mode = getListFilterMode(cfg);
     String[] addresses = cfg.getStringList("receiveemail", "filter", "patterns");
     String concat = Arrays.asList(addresses).stream().collect(joining("|"));
     this.mailPattern = Pattern.compile(concat);
   }
 
+  private static final String LEGACY_ALLOW = "WHITELIST";
+  private static final String LEGACY_BLOCK = "BLACKLIST";
+
+  /** Legacy names are supported, but should be removed in the future. */
+  private ListFilterMode getListFilterMode(Config cfg) {
+    ListFilterMode mode;
+    String modeString = cfg.getString("receiveemail", "filter", "mode");
+    if (modeString == null) {
+      modeString = "";
+    }
+    switch (modeString) {
+      case LEGACY_ALLOW:
+      case "ALLOW":
+        mode = ListFilterMode.ALLOW;
+        break;
+      case LEGACY_BLOCK:
+      case "BLOCK":
+        mode = ListFilterMode.BLOCK;
+        break;
+      default:
+        mode = ListFilterMode.OFF;
+    }
+    return mode;
+  }
+
   @Override
   public boolean shouldProcessMessage(MailMessage message) {
     if (mode == ListFilterMode.OFF) {
@@ -53,8 +78,7 @@
     }
 
     boolean match = mailPattern.matcher(message.from().email()).find();
-    if ((mode == ListFilterMode.WHITELIST && !match)
-        || (mode == ListFilterMode.BLACKLIST && match)) {
+    if ((mode == ListFilterMode.ALLOW && !match) || (mode == ListFilterMode.BLOCK && match)) {
       logger.atInfo().log("Mail message from %s rejected by list filter", message.from());
       return false;
     }
diff --git a/javatests/com/google/gerrit/acceptance/server/mail/ListMailFilterIT.java b/javatests/com/google/gerrit/acceptance/server/mail/ListMailFilterIT.java
index e961c67..49b184b 100644
--- a/javatests/com/google/gerrit/acceptance/server/mail/ListMailFilterIT.java
+++ b/javatests/com/google/gerrit/acceptance/server/mail/ListMailFilterIT.java
@@ -45,11 +45,11 @@
   }
 
   @Test
-  @GerritConfig(name = "receiveemail.filter.mode", value = "WHITELIST")
+  @GerritConfig(name = "receiveemail.filter.mode", value = "ALLOW")
   @GerritConfig(
       name = "receiveemail.filter.patterns",
       values = {".+ser@example\\.com", "a@b\\.com"})
-  public void listFilterWhitelistDoesNotFilterListedUser() throws Exception {
+  public void listFilterAllowDoesNotFilterListedUser() throws Exception {
     ChangeInfo changeInfo = createChangeAndReplyByEmail();
     // Check that the comments from the email have been persisted
     Collection<ChangeMessageInfo> messages = gApi.changes().id(changeInfo.id).get().messages;
@@ -57,11 +57,11 @@
   }
 
   @Test
-  @GerritConfig(name = "receiveemail.filter.mode", value = "WHITELIST")
+  @GerritConfig(name = "receiveemail.filter.mode", value = "ALLOW")
   @GerritConfig(
       name = "receiveemail.filter.patterns",
       values = {".+@gerritcodereview\\.com", "a@b\\.com"})
-  public void listFilterWhitelistFiltersNotListedUser() throws Exception {
+  public void listFilterAllowFiltersNotListedUser() throws Exception {
     ChangeInfo changeInfo = createChangeAndReplyByEmail();
     // Check that the comments from the email have NOT been persisted
     Collection<ChangeMessageInfo> messages = gApi.changes().id(changeInfo.id).get().messages;
@@ -72,11 +72,11 @@
   }
 
   @Test
-  @GerritConfig(name = "receiveemail.filter.mode", value = "BLACKLIST")
+  @GerritConfig(name = "receiveemail.filter.mode", value = "BLOCK")
   @GerritConfig(
       name = "receiveemail.filter.patterns",
       values = {".+@gerritcodereview\\.com", "a@b\\.com"})
-  public void listFilterBlacklistDoesNotFilterNotListedUser() throws Exception {
+  public void listFilterBlockDoesNotFilterNotListedUser() throws Exception {
     ChangeInfo changeInfo = createChangeAndReplyByEmail();
     // Check that the comments from the email have been persisted
     Collection<ChangeMessageInfo> messages = gApi.changes().id(changeInfo.id).get().messages;
@@ -84,11 +84,11 @@
   }
 
   @Test
-  @GerritConfig(name = "receiveemail.filter.mode", value = "BLACKLIST")
+  @GerritConfig(name = "receiveemail.filter.mode", value = "BLOCK")
   @GerritConfig(
       name = "receiveemail.filter.patterns",
       values = {".+@example\\.com", "a@b\\.com"})
-  public void listFilterBlacklistFiltersListedUser() throws Exception {
+  public void listFilterBlockFiltersListedUser() throws Exception {
     ChangeInfo changeInfo = createChangeAndReplyByEmail();
     // Check that the comments from the email have been persisted
     Collection<ChangeMessageInfo> messages = gApi.changes().id(changeInfo.id).get().messages;