Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/filterClasses.js

Issue 29790629: Issue 6690 - Always ignore trailing dot in document domain (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Ignore trailing dot in ElemHide.getSelectorsForDomain Created May 26, 2018, 12:10 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/elemHide.js ('k') | test/domainRestrictions.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterClasses.js
===================================================================
--- a/lib/filterClasses.js
+++ b/lib/filterClasses.js
@@ -381,23 +381,16 @@
/**
* Separator character used in domainSource property, must be
* overridden by subclasses
* @type {string}
*/
domainSeparator: null,
/**
- * Determines whether the trailing dot in domain names isn't important and
- * should be ignored, must be overridden by subclasses.
- * @type {boolean}
- */
- ignoreTrailingDot: true,
-
- /**
* Determines whether domainSource is already upper-case,
* can be overridden by subclasses.
* @type {boolean}
*/
domainSourceIsUpperCase: false,
/**
* Map containing domains that this filter should match on/not match
@@ -421,28 +414,24 @@
{
// RegExpFilter already have uppercase domains
source = source.toUpperCase();
}
let list = source.split(this.domainSeparator);
if (list.length == 1 && list[0][0] != "~")
{
// Fast track for the common one-domain scenario
- if (this.ignoreTrailingDot)
- list[0] = list[0].replace(/\.+$/, "");
domains = new Map([["", false], [list[0], true]]);
}
else
{
let hasIncludes = false;
for (let i = 0; i < list.length; i++)
{
let domain = list[i];
- if (this.ignoreTrailingDot)
- domain = domain.replace(/\.+$/, "");
if (domain == "")
continue;
let include;
if (domain[0] == "~")
{
include = false;
domain = domain.substr(1);
@@ -496,19 +485,17 @@
if (!this.domains)
return true;
// If the document has no host name, match only if the filter
// isn't restricted to specific domains
if (!docDomain)
return this.domains.get("");
- if (this.ignoreTrailingDot)
- docDomain = docDomain.replace(/\.+$/, "");
- docDomain = docDomain.toUpperCase();
+ docDomain = docDomain.replace(/\.+$/, "").toUpperCase();
while (true)
{
let isDomainIncluded = this.domains.get(docDomain);
if (typeof isDomainIncluded != "undefined")
return isDomainIncluded;
let nextDot = docDomain.indexOf(".");
@@ -524,19 +511,17 @@
* @param {string} docDomain
* @return {boolean}
*/
isActiveOnlyOnDomain(docDomain)
{
if (!docDomain || !this.domains || this.domains.get(""))
return false;
- if (this.ignoreTrailingDot)
- docDomain = docDomain.replace(/\.+$/, "");
- docDomain = docDomain.toUpperCase();
+ docDomain = docDomain.replace(/\.+$/, "").toUpperCase();
for (let [domain, isIncluded] of this.domains)
{
if (isIncluded && domain != docDomain)
{
if (domain.length <= docDomain.length)
return false;
@@ -1010,21 +995,16 @@
ElemHideBase.prototype = extend(ActiveFilter, {
/**
* @see ActiveFilter.domainSeparator
*/
domainSeparator: ",",
/**
- * @see ActiveFilter.ignoreTrailingDot
- */
- ignoreTrailingDot: false,
-
- /**
* Host names or domains the filter should be restricted to (can be null for
* no restriction)
* @type {?string}
*/
selectorDomains: null,
/**
* CSS selector for the HTML elements that should be hidden
* @type {string}
« no previous file with comments | « lib/elemHide.js ('k') | test/domainRestrictions.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld