Ignore validating class name of isolated process name

Fix #4176

Co-authored-by: topjohnwu <topjohnwu@gmail.com>
This commit is contained in:
vvb2060 2021-04-16 14:08:51 +08:00 committed by GitHub
parent 2b65e1ffc2
commit f4ac7c8e7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -99,24 +99,40 @@ static void kill_process(const char *name, bool multi = false,
});
}
static bool validate(const char *s) {
if (strcmp(s, ISOLATED_MAGIC) == 0)
return true;
bool dot = false;
for (char c; (c = *s); ++s) {
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||
(c >= '0' && c <= '9') || c == '_' || c == ':') {
static bool validate(const char *pkg, const char *proc) {
bool pkg_valid = false;
bool proc_valid = true;
if (str_eql(pkg, ISOLATED_MAGIC)) {
pkg_valid = true;
for (char c; (c = *proc); ++proc) {
if (isalnum(c) || c == '_' || c == '.')
continue;
if (c == ':')
break;
proc_valid = false;
break;
}
if (SDK_INT >= 29 && c == '$')
} else {
for (char c; (c = *pkg); ++pkg) {
if (isalnum(c) || c == '_')
continue;
if (c == '.') {
dot = true;
pkg_valid = true;
continue;
}
return false;
pkg_valid = false;
break;
}
return dot;
for (char c; (c = *proc); ++proc) {
if (isalnum(c) || c == '_' || c == ':' || c == '.')
continue;
proc_valid = false;
break;
}
}
return pkg_valid && proc_valid;
}
static void add_hide_set(const char *pkg, const char *proc) {
@ -134,7 +150,7 @@ static int add_list(const char *pkg, const char *proc) {
if (proc[0] == '\0')
proc = pkg;
if (!validate(pkg) || !validate(proc))
if (!validate(pkg, proc))
return HIDE_INVALID_PKG;
for (auto &hide : hide_set)