Skip to content

Commit

Permalink
Normalize Adguard's plain cosmetic filters disguised as style-based f…
Browse files Browse the repository at this point in the history
…ilters

Reported by https://github.com/uBlock-user in
https://github.com/orgs/uBlockOrigin/teams/ublock-issues-volunteers/discussions/56

For some reasons, many cosmetic filters in Adguard's Annoyance List
are plain cosmetic filters disguised as style-based cosmetic filters,
and this was breaking uBO's ability to reverse lookup such filters
from the logger.
  • Loading branch information
gorhill committed Dec 23, 2018
1 parent 96fe5f7 commit e2d1f50
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/js/static-ext-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,16 @@
};

const translateAdguardCSSInjectionFilter = function(suffix) {
var matches = /^([^{]+)\{([^}]+)\}$/.exec(suffix);
const matches = /^([^{]+)\{([^}]+)\}$/.exec(suffix);
if ( matches === null ) { return ''; }
return matches[1].trim() + ':style(' + matches[2].trim() + ')';
const selector = matches[1].trim();
const style = matches[2].trim();
// For some reasons, many of Adguard's plain cosmetic filters are
// "disguised" as style-based cosmetic filters: convert such filters
// to plain cosmetic filters.
return /display\s*:\s*none\s*!important;?$/.test(style)
? selector
: selector + ':style(' + style + ')';
};

const hostnamesFromPrefix = function(s) {
Expand Down

6 comments on commit e2d1f50

@uBlock-user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to 1.17.5b17 and still no change, I can still reproduce the issue.

@gwarser
Copy link
Contributor

@gwarser gwarser commented on e2d1f50 Dec 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With different filter?

@uBlock-user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no same filter.

@gorhill
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to force a re-compile of the list (purge, update), or else uBO uses the old compiled version which is what causes the issue.

@uBlock-user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

force update Adguard annoyance list or ALL of them ?

@uBlock-user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm, force updating Adguard's Annoyance List did the job.

Please sign in to comment.