From 4d3fd8fed137159305427af377349b3c52664315 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Tue, 27 Oct 2026 00:05:38 +0800 Subject: [PATCH] Validate URL-REGEX Source During Build Process --- Build/lib/rules/base.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Build/lib/rules/base.ts b/Build/lib/rules/base.ts index 4e227476..94d5254e 100644 --- a/Build/lib/rules/base.ts +++ b/Build/lib/rules/base.ts @@ -263,11 +263,13 @@ export class FileOutput { this.processName.add(value); } break; - case 'URL-REGEX': { - const [, ...rest] = splitted; - this.urlRegex.add(rest.join(',')); + case 'URL-REGEX': + // Surge splits rule lines on `,`, a comma in the regex (e.g. `\d{1,3}`) truncates the pattern + if (splitted.length > 2) { + throw new TypeError(`URL-REGEX must not contain ",": ${line}`); + } + this.urlRegex.add(value); break; - } case 'IP-CIDR': (arg === 'no-resolve' ? this.ipcidrNoResolve : this.ipcidr).add(value); break;