Skip to content

Commit

Permalink
Fix highligthing of FQDN match in logger
Browse files Browse the repository at this point in the history
Related feedback:
- uBlockOrigin/uAssets#7619 (comment)

Also fixed strict-blocking of URL using FQDN.
  • Loading branch information
gorhill committed Jul 3, 2020
1 parent 324b4fe commit 941898e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/js/static-net-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ const FilterAnchorHn = class extends FilterAnchorHnLeft {
logData(details) {
super.logData(details);
details.pattern.push('^');
details.regex.push(restrSeparator);
details.regex.push('\\.?', restrSeparator);
}

toSelfie() {
Expand Down Expand Up @@ -1709,7 +1709,7 @@ const FilterHostnameDict = class {

logData(details) {
details.pattern.push('||', this.$h, '^');
details.regex.push(restrFromPlainPattern(this.$h), restrSeparator);
details.regex.push(restrFromPlainPattern(this.$h), '\\.?', restrSeparator);
}

toSelfie() {
Expand Down
10 changes: 7 additions & 3 deletions src/js/traffic.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,13 @@ const toBlockDocResult = function(url, hostname, logData) {
// /~https://github.com/chrisaljoudi/uBlock/issues/1212
// 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;
// /~https://github.com/uBlockOrigin/uAssets/issues/7619#issuecomment-653010310
// Also match FQDN.
const hnpos = url.indexOf(hostname);
const hnlen = hostname.length;
const end = match.index + match[0].length - hnpos - hnlen;
return end === 0 || end === 1 ||
end === 2 && url.charCodeAt(hnpos + hnlen) === 0x2E /* '.' */;
};

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

0 comments on commit 941898e

Please sign in to comment.