adblock: fold the regex path into the existing mechanisms

The raw URL lives on `pattern.Url` next to the lowercased one, so
`pattern.matches` owns the `.regex` arm like every other kind and the
engine stops special-casing it. `Request.init` does the lowercasing
itself, as `fromHttp` already had to, instead of asking callers for
both spellings.

The regex shape now spells its uncertain marker as `*` and keeps
non-token literals as one marker, so it is read by the same
bounded-token loop as a plain pattern rather than a copy of it. The
quantifier parser keeps only what it uses: whether the atom may be
absent.

`Regex.matches` runs on a stack-first allocator: PCRE2 wants a match
data block and 20KB of backtracking frames per call, which no longer
touches the heap in the common case. A filter holds a pointer to its
regex, keeping `NetworkFilter` at its previous size.
This commit is contained in:
Adrià Arrufat committed 2026-09-09 13:13:18 +02:00
1 parent 39974e461d
commit 433ca9b747
6 files changed
+110 -126

No files matched your search

-4
View File
@@ -4314,10 +4314,6 @@ test "HttpClient: adblock verdicts apply per request" {
.url = "https://cdn.example.com/ABCD.js",
.resource_type = .script,
}));
try testing.expect(!testIsUrlBlocked(&client, .{
.url = "https://cdn.example.com/abcd.js",
.resource_type = .xhr,
}));
try testing.expect(testIsUrlBlocked(&client, .{ .url = "https://ads.example.com/pixel.gif" }));
// Hostnames are matched case-insensitively and without the port.