Skip to content

Commit

Permalink
Strict-block only if match is anchored to end of hostname
Browse files Browse the repository at this point in the history
As per feedback from filter list maintainers.
  • Loading branch information
gorhill committed Jul 2, 2019
1 parent 9d198a2 commit 41636c5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/js/traffic.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,11 @@ const toBlockDocResult = function(url, hostname, logData) {

// https://github.com/chrisaljoudi/uBlock/issues/1128
// https://github.com/chrisaljoudi/uBlock/issues/1212
// Relax the rule: verify that the match is completely before the path part
return (match.index + match[0].length) <=
(url.indexOf(hostname) + hostname.length + 1);
// Verify that the end of the match is anchored to the end of the
// hostname.
const end = match.index + match[0].length -
url.indexOf(hostname) - hostname.length;
return end === 0 || end === 1;
};

/******************************************************************************/
Expand Down

1 comment on commit 41636c5

@gwarser
Copy link
Contributor

@gwarser gwarser commented on 41636c5 Aug 2, 2019

Choose a reason for hiding this comment

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

The feedback was https://github.com/orgs/uBlockOrigin/teams/ublock-issues-volunteers/discussions/110:

if we have a filter like (lots of false positive - treated by unbreak list):
://ads.$domain=~ads.ac.uk|~ads.adstream.com.ro|...

I propose not to block the whole domain if:

  • first party and not intended to totally block that domain (filters like ||example.com^ )

Now a site like https://ads.buscaempresas.co will be broken and a badfilter + excluding the domain for that sort of filter is necessary

Please sign in to comment.