fix(validator,migration,fuzzer): resilient domain validation, strip prefixed comments and fix zapret1 fuzzer fwmark

This commit is contained in:
Dushnilin
2026-09-09 21:44:43 +03:00
parent 9d7e53f260
commit 7fe6a84f80
10 changed files with 87 additions and 20 deletions
@@ -1046,7 +1046,13 @@ function validateProxyUrl(url) {
// src/helpers/parseValueList.ts
function parseValueList(value) {
return value.split(/\n/).map((line) => line.split("//")[0].split("#")[0]).join(" ").split(/[,\s]+/).map((s) => s.trim()).filter(Boolean);
return value.split(/\r?\n/).map((line) => {
const stripped = line.replace(
/^(full|keyword|regex):[ \t]*(\/\/|#).*$/,
""
);
return stripped.split("//")[0].split("#")[0];
}).join(" ").split(/[,\s]+/).map((s) => s.trim()).filter(Boolean);
}
// src/helpers/getProxyUrlName.ts
@@ -5521,8 +5521,9 @@ function parseCommentAwareListTokens(value) {
let offset = 0;
lines.forEach((line, index) => {
const hashIndex = line.indexOf("#");
const slashIndex = line.indexOf("//");
const cleanLine = line.replace(/^(full|keyword|regex):[ \t]*(\/\/|#).*$/, "");
const hashIndex = cleanLine.indexOf("#");
const slashIndex = cleanLine.indexOf("//");
let commentIndex = -1;
if (hashIndex >= 0 && slashIndex >= 0) {
@@ -5533,7 +5534,7 @@ function parseCommentAwareListTokens(value) {
commentIndex = slashIndex;
}
const source = commentIndex >= 0 ? line.slice(0, commentIndex) : line;
const source = commentIndex >= 0 ? cleanLine.slice(0, commentIndex) : cleanLine;
const matcher = /[^,\s]+/g;
let match;