Unverified Commit f4ac7c8e authored by vvb2060's avatar vvb2060 Committed by GitHub

Ignore validating class name of isolated process name

Fix #4176
Co-authored-by: 's avatartopjohnwu <topjohnwu@gmail.com>
parent 2b65e1ff
......@@ -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;
}
for (char c; (c = *proc); ++proc) {
if (isalnum(c) || c == '_' || c == ':' || c == '.')
continue;
proc_valid = false;
break;
}
}
return dot;
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment