From 941898e54ee5dd009f9af15e9ed9954e2297ddc4 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 3 Jul 2020 14:28:03 -0400 Subject: [PATCH] Fix highligthing of FQDN match in logger Related feedback: - https://github.com/uBlockOrigin/uAssets/issues/7619#issuecomment-653010310 Also fixed strict-blocking of URL using FQDN. --- src/js/static-net-filtering.js | 4 ++-- src/js/traffic.js | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index 35f674e90..2ead51f33 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -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() { @@ -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() { diff --git a/src/js/traffic.js b/src/js/traffic.js index 622f89030..74792edb9 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -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 /* '.' */; }; /******************************************************************************/