Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check domains validity when parsing network filters #4525

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
test: NetworkFilter.prototype.toString to omit | as sep
  • Loading branch information
seia-soto committed Dec 25, 2024
commit 7e4743ad8532da9db81f756bff0a0b2e39180c92
5 changes: 4 additions & 1 deletion packages/adblocker/test/parsing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { parseFilters } from '../src/lists.js';
import { hashStrings, tokenize } from '../src/utils.js';
import { HTMLSelector, HTMLModifier } from '../src/html-filtering.js';
import { NORMALIZED_TYPE_TOKEN, hashHostnameBackward } from '../src/request.js';
import { Domains, normalizeNetworkEntities } from '../src/engine/domains.js';
import { normalizeNetworkEntities } from '../src/engine/domains.js';

function h(hostnames: string[]): Uint32Array {
return new Uint32Array(hostnames.map(hashHostnameBackward)).sort();
Expand Down Expand Up @@ -181,6 +181,9 @@ describe('Network filters', () => {

it('pprint domain', () => {
checkToString('ads$domain=foo.com|bar.co.uk|~baz.io', 'ads$domain=<hashed>');
checkToString('ads$domain=foo.com|bar.com', 'ads$domain=foo.com|bar.com', true);
checkToString('ads$denyallow=foo.com|bar.co.uk|~baz.io', 'ads$denyallow=<hashed>');
checkToString('ads$denyallow=foo.com|bar.com', 'ads$denyallow=foo.com|bar.com', true);
});

it('pprint with debug=true', () => {
Expand Down
Loading