Merge pull request #3463 from lightpanda-io/adblock-regex-pcre2

`AdBlocker`: run /regex/ filters with PCRE2
This commit is contained in:
Adrià Arrufat authored and GitHub committed 2026-09-10 14:04:14 +02:00
commit d693f49872
8 files changed
+778 -65

No files matched your search

+15
View File
@@ -4390,12 +4390,27 @@ test "HttpClient: adblock verdicts apply per request" {
\\||typed.example.com^$script
\\||partied.example.com^$third-party
\\||framed.example.com^$subdocument
\\/\/[a-z]{4}\.js$/$match-case,script
);
try blocker.parse(&list);
try blocker.build();
client.network.adblocker = blocker;
defer client.network.adblocker = null;
// A regex filter reads the URL as requested: case kept, fragment gone.
try testing.expect(testIsUrlBlocked(&client, .{
.url = "https://cdn.example.com/abcd.js",
.resource_type = .script,
}));
try testing.expect(testIsUrlBlocked(&client, .{
.url = "https://cdn.example.com/abcd.js#v2",
.resource_type = .script,
}));
try testing.expect(!testIsUrlBlocked(&client, .{
.url = "https://cdn.example.com/ABCD.js",
.resource_type = .script,
}));
try testing.expect(testIsUrlBlocked(&client, .{ .url = "https://ads.example.com/pixel.gif" }));
// Hostnames are matched case-insensitively and without the port.
try testing.expect(testIsUrlBlocked(&client, .{ .url = "https://SUB.ADS.EXAMPLE.COM:8443/x" }));