COIL: Rename "whitelist" in utils.py
Per go/coil, ChromeOS has a P1 Q3 OKR to remove oppressive language from
the code base, including replacing "whitelist" with "allowlist". This CL
addresses instances of "whitelist" in client/common_lib/utils.py.
BUG=b:159917945
TEST=utils_unittest.py
TEST=grep for sh_quote_word, verify nobody was calling the whitelist
kwarg by name
Change-Id: I12c4d410d3436bd126168150ba30ff09251d710e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2270642
Commit-Queue: Greg Edelston <gredelston@google.com>
Tested-by: Greg Edelston <gredelston@google.com>
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
diff --git a/client/common_lib/utils.py b/client/common_lib/utils.py
index 2ea480f..cf35723 100644
--- a/client/common_lib/utils.py
+++ b/client/common_lib/utils.py
@@ -93,7 +93,7 @@
STDERR_PREFIX = '[stderr] '
# safe characters for the shell (do not need quoting)
-SHELL_QUOTING_WHITELIST = frozenset(string.ascii_letters +
+_SHELL_QUOTING_ALLOWLIST = frozenset(string.ascii_letters +
string.digits +
'_-+=>')
@@ -1626,7 +1626,7 @@
return command
-def sh_quote_word(text, whitelist=SHELL_QUOTING_WHITELIST):
+def sh_quote_word(text, allowlist=_SHELL_QUOTING_ALLOWLIST):
r"""Quote a string to make it safe as a single word in a shell command.
POSIX shell syntax recognizes no escape characters inside a single-quoted
@@ -1646,12 +1646,12 @@
sh_quote_word('echo %s' % sh_quote_word('hello world')))
@param text: The string to be quoted into a single word for the shell.
- @param whitelist: Optional list of characters that do not need quoting.
+ @param allowlist: Optional list of characters that do not need quoting.
Defaults to a known good list of characters.
@return A string, possibly quoted, safe as a single word for a shell.
"""
- if all(c in whitelist for c in text):
+ if all(c in allowlist for c in text):
return text
return "'" + text.replace("'", r"'\''") + "'"