Allow special characters in rule-set tags
Some checks failed
Build and Deploy Gateway / build-and-deploy (push) Failing after 13s
Some checks failed
Build and Deploy Gateway / build-and-deploy (push) Failing after 13s
This commit is contained in:
@@ -21,9 +21,12 @@ import { matchRoute, detectRuleConflicts } from "./routeMatcher.js";
|
||||
import { tcpPing, resolveHost } from "./ping.js";
|
||||
|
||||
const APPLY_HISTORY_LIMIT = 10;
|
||||
const RULE_SET_TAG_RE = /^[a-z0-9][a-z0-9_.@!-]*$/i;
|
||||
const FALLBACK_RULE_SET_CATALOG = {
|
||||
geosite: [
|
||||
"geosite-category-ru",
|
||||
"geosite-category-ai-!cn",
|
||||
"geosite-geolocation-!cn",
|
||||
"geosite-google",
|
||||
"geosite-youtube",
|
||||
"geosite-telegram",
|
||||
@@ -648,7 +651,7 @@ function normalizeCustomRules(input) {
|
||||
["tcp", "udp"].includes(network),
|
||||
),
|
||||
ruleSets: normalizeList(rule.ruleSets).filter((tag) =>
|
||||
/^[a-z0-9][a-z0-9-]*$/i.test(tag),
|
||||
RULE_SET_TAG_RE.test(tag),
|
||||
),
|
||||
}));
|
||||
}
|
||||
@@ -938,7 +941,7 @@ async function handleApi(req, res) {
|
||||
url: String(rs.url).trim(),
|
||||
format: rs.format === "source" ? "source" : "binary",
|
||||
}))
|
||||
.filter((rs) => /^[a-z0-9][a-z0-9-]*$/i.test(rs.tag));
|
||||
.filter((rs) => RULE_SET_TAG_RE.test(rs.tag));
|
||||
writeJson(settings.customRuleSetsPath, normalized);
|
||||
return sendJson(res, 200, { success: true, ruleSets: normalized });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user