1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-19 16:25:50 +00:00

Use inclusive terminology (#1137)

This commit is contained in:
Otto Winter
2020-07-14 18:45:42 +02:00
committed by GitHub
parent 5776e70d7c
commit 412351fd1e
7 changed files with 35 additions and 16 deletions

View File

@@ -85,16 +85,16 @@ std::string to_lowercase_underscore(std::string s) {
return s;
}
std::string sanitize_string_whitelist(const std::string &s, const std::string &whitelist) {
std::string sanitize_string_allowlist(const std::string &s, const std::string &allowlist) {
std::string out(s);
out.erase(std::remove_if(out.begin(), out.end(),
[&whitelist](const char &c) { return whitelist.find(c) == std::string::npos; }),
[&allowlist](const char &c) { return allowlist.find(c) == std::string::npos; }),
out.end());
return out;
}
std::string sanitize_hostname(const std::string &hostname) {
std::string s = sanitize_string_whitelist(hostname, HOSTNAME_CHARACTER_WHITELIST);
std::string s = sanitize_string_allowlist(hostname, HOSTNAME_CHARACTER_ALLOWLIST);
return truncate_string(s, 63);
}
@@ -154,7 +154,7 @@ ParseOnOffState parse_on_off(const char *str, const char *on, const char *off) {
return PARSE_NONE;
}
const char *HOSTNAME_CHARACTER_WHITELIST = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
const char *HOSTNAME_CHARACTER_ALLOWLIST = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
uint8_t crc8(uint8_t *data, uint8_t len) {
uint8_t crc = 0;