Skip to content

Commit

Permalink
merge the parent branch into the current branch, resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
slavaleleka committed Oct 10, 2024
2 parents a9ee6b6 + 1b11eb8 commit ad891a5
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 13 deletions.
23 changes: 18 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,31 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
<!-- FIXME: add release date -->
## [v1.2.1]

## Added

- [@adguard/agtree] v2.1.2 for rules conversion and validation
<!-- FIXME: mention the latest version of agtree if needed -->
- [@adguard/agtree] v2.1.2 for rules conversion and validation.

### Changed

- Updated [@adguard/scriptlets] to v1.11.27
- Updated [@adguard/tsurlfilter] to v3.0.4
<!-- FIXME: use the latest versions of scriptlets and tsurlfilter -->
- Updated [@adguard/scriptlets] to v1.11.27.
- Updated [@adguard/tsurlfilter] to v3.0.4.

[Unreleased]: https://github.com/AdguardTeam/FiltersCompiler/compare/v1.1.146...HEAD
[v1.2.1]: https://github.com/AdguardTeam/FiltersCompiler/compare/v1.1.148...v1.2.1


## [v1.1.148] - 2024-10-02

### Changed

- Exclude `$redirect-rule` from filters for MV3 extension [#231]

[v1.1.148]: https://github.com/AdguardTeam/FiltersCompiler/compare/v1.1.146...v1.1.148
[#231]: https://github.com/AdguardTeam/FiltersCompiler/issues/231


## [v1.1.146] - 2024-08-29
Expand Down
5 changes: 4 additions & 1 deletion src/main/platforms-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,10 @@ module.exports = {
'path': 'extension/chromium-mv3',
'expires': '10 days',
'configuration': {
'removeRulePatterns': CHROMIUM_BASED_EXTENSION_PATTERNS,
'removeRulePatterns': [
...CHROMIUM_BASED_EXTENSION_PATTERNS,
...REDIRECT_MODIFIER_PATTERNS,
],
'replacements': null,
'ignoreRuleHints': false,
},
Expand Down
41 changes: 38 additions & 3 deletions src/test/builder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ describe('Test builder', () => {
it('platforms/test filters 5.txt', async () => {
const filterContent = await readFile(path.join(__dirname, 'resources/platforms/test', 'filters', '5.txt'));
const filterLines = filterContent.split(/\r?\n/);
expect(filterLines.length).toEqual(54);
expect(filterLines.length).toEqual(55);

const presentRules = [
'||adsnet.com/*/700x350.gif$domain=example.com',
Expand Down Expand Up @@ -293,7 +293,7 @@ describe('Test builder', () => {
it('platforms/test2 filters 5.txt', async () => {
const filterContent = await readFile(path.join(__dirname, 'resources/platforms/test2', 'filters', '5.txt'));
const filterLines = filterContent.split(/\r?\n/);
expect(filterLines.length).toEqual(54);
expect(filterLines.length).toEqual(55);

const presentRules = [
'test.com#%#//scriptlet(\'abp-abort-on-property-read\', \'adsShown\')',
Expand Down Expand Up @@ -584,6 +584,41 @@ describe('Test builder', () => {
});
});

it('platforms/chromium-mv3 filters 2.txt', async () => {
const filterContent = await readFile(path.join(platformsDir, 'chromium-mv3', 'filters', '2.txt'));
expect(filterContent).toBeTruthy();

const filterLines = filterContent.split(/\r?\n/);
expect(filterLines.length).toEqual(56);

// expires value in set from the filters metadata
// if there is no 'expires' property in platform.json for the platform
expect(filterLines.includes('! Expires: 2 days (update frequency)')).toBeTruthy();

const presentLines = [
'test_domain#%#testScript();',
'test.com#%#var isadblock=1;',
'example.org#@%#navigator.getBattery = undefined;',
'test.com#%#//scriptlet(\'ubo-abort-on-property-read.js\', \'Object.prototype.getBanner\')',
'example.net#$?#.main-content { margin-top: 0!important; }',
'test.com#@$?#.banner { padding: 0!important; }',
'example.net#?#.banner:matches-css(width: 360px)',
'test.com#@?#.banner:matches-css(height: 200px)',
];
presentLines.forEach((rule) => {
expect(filterLines.includes(rule)).toBeTruthy();
});

const absentLines = [
'||example.com^$script,redirect-rule=noopjs',
'*$redirect-rule=noopjs,xmlhttprequest,domain=example.com',
];

absentLines.forEach((rule) => {
expect(filterLines.includes(rule)).toBeFalsy();
});
});

describe('check MAC platform', () => {
it('platform/mac filters.json', async () => {
const macFiltersMetadataContent = await readFile(path.join(platformsDir, 'mac', 'filters.json'));
Expand Down Expand Up @@ -701,7 +736,7 @@ describe('Test builder', () => {
expect(filterContent).toBeTruthy();

const filterLines = filterContent.split(/\r?\n/);
expect(filterLines.length).toEqual(53);
expect(filterLines.length).toEqual(54);
expect(filterLines.includes('||example.com^$script,redirect=noopjs')).toBeTruthy();
expect(filterLines.includes('||example.com/banner$image,redirect=1x1-transparent.gif')).toBeTruthy();
});
Expand Down
40 changes: 40 additions & 0 deletions src/test/platforms-filter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,46 @@ describe('platforms filter', () => {
expect(after).toEqual(notMatchRules);
});

it('Test removing `redirect-rule=` modifier', () => {
const config = {
'platform': 'test',
'path': 'hints',
'configuration': {
'removeRulePatterns': [
'\\$redirect-rule=',
',redirect-rule=',
],
'ignoreRuleHints': false,
},
};

const notMatchRules = [
'! Comment',
'example.com',
'example.com,content-examples.com###ad3',
'@@||example.com^$elemhide,content,jsinject',
'@@||example.com^$elemhide,jsinject,content',
'@@||content.com$stealth',
'example.com##.sidebar_list > .widget_text:has(a[title = "content"])',
'||dai.google.com/ondemand/hls/content/*.m3u8$hls=/redirector\.googlevideo\.com\/,domain=sbs.com.au',
];
const matchRules = [
'||example.com/script.json$xmlhttprequest,redirect-rule=noopjson',
'||example.com/script.js$script,redirect-rule=noopjs',
'*$redirect-rule=noopjs,xmlhttprequest,domain=example.com',
];

const before = [
...notMatchRules,
...matchRules,
];

const after = filter.cleanupRules(before, config, 0);

expect(after).toBeDefined();
expect(after).toEqual(notMatchRules);
});

it('Test removing of single content modifier', () => {
const config = {
'platform': 'test',
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/filters/filter_5_TrustLevel/filter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ example.com##div.grid_1[class$="app"]
||test.com^$script,redirect=noopjs
||example.com/*.mp4$media,redirect=noopmp4-1s
||example.com^$script,redirect-rule=noopjs
*$redirect-rule=noopjs,xmlhttprequest,domain=example.com
!
6 changes: 3 additions & 3 deletions src/test/resources/filters/filter_5_TrustLevel/revision.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.0.1",
"timeUpdated": 1724275516306,
"hash": "w67DhUNcA8KqwoUuwqbCgcOdC33DnQQt"
"version": "1.0.0.3",
"timeUpdated": 1727881072037,
"hash": "Zm3CvkdZdU3Ci8O5Jmsfwr9ew7/DpQ=="
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ example.com##div.grid_1[class$="app"]
||test.com^$script,rewrite=abp-resource:blank-js
||example.com/*.mp4$media,redirect=noopmp4-1s
||example.com^$script,redirect-rule=noopjs
*$redirect-rule=noopjs,xmlhttprequest,domain=example.com
!
example.com#%#//scriptlet('trusted-set-local-storage-item', 'iName', 'iValue')
example.com#%#//scriptlet("trusted-set-cookie", "cName", "cValue")
5 changes: 4 additions & 1 deletion src/test/resources/platforms.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@
"platform": "ext_chromium_mv3",
"path": "chromium-mv3",
"configuration": {
"removeRulePatterns": false,
"removeRulePatterns": [
"\\$redirect-rule=",
",redirect-rule="
],
"ignoreRuleHints": false
},
"defines": {
Expand Down

0 comments on commit ad891a5

Please sign in to comment.