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

Unified Diff: lib/filterClasses.js

Issue 29757595: Noissue - Use plural for element hiding domains (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Rebase Created May 2, 2018, 1:34 p.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 | « no previous file | test/filterClasses.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
@@ -183,18 +183,18 @@
// Don't remove spaces inside comments
if (/^ *!/.test(text))
return text.trim();
// Special treatment for element hiding filters, right side is allowed to
// contain spaces
if (Filter.elemhideRegExp.test(text))
{
- let [, domain, separator, selector] = /^(.*?)(#[@?]?#?)(.*)$/.exec(text);
- return domain.replace(/ +/g, "") + separator + selector.trim();
+ let [, domains, separator, selector] = /^(.*?)(#[@?]?#?)(.*)$/.exec(text);
+ return domains.replace(/ +/g, "") + separator + selector.trim();
}
// For most regexp filters we strip all spaces, but $csp filter options
// are allowed to contain single (non trailing) spaces.
let strippedText = text.replace(/ +/g, "");
if (!strippedText.includes("$") || !/\bcsp=/i.test(strippedText))
return strippedText;
@@ -960,18 +960,18 @@
* @augments ActiveFilter
*/
function ElemHideBase(text, domains, selector)
{
ActiveFilter.call(this, text, domains || null);
if (domains)
{
- this.selectorDomain = domains.replace(/,~[^,]+/g, "")
- .replace(/^~[^,]+,?/, "").toLowerCase();
+ this.selectorDomains = domains.replace(/,~[^,]+/g, "")
+ .replace(/^~[^,]+,?/, "").toLowerCase();
}
// Braces are being escaped to prevent CSS rule injection.
this.selector = selector.replace("{", "\\7B ").replace("}", "\\7D ");
}
exports.ElemHideBase = ElemHideBase;
ElemHideBase.prototype = extend(ActiveFilter, {
@@ -981,62 +981,62 @@
domainSeparator: ",",
/**
* @see ActiveFilter.ignoreTrailingDot
*/
ignoreTrailingDot: false,
/**
- * Host name or domain the filter should be restricted to (can be null for
+ * Host names or domains the filter should be restricted to (can be null for
* no restriction)
* @type {string}
*/
- selectorDomain: null,
+ selectorDomains: null,
/**
* CSS selector for the HTML elements that should be hidden
* @type {string}
*/
selector: null
});
/**
* Creates an element hiding filter from a pre-parsed text representation
*
* @param {string} text same as in Filter()
- * @param {string?} domain
- * domain part of the text representation
+ * @param {string?} domains
+ * domains part of the text representation
* @param {string?} type
* rule type, either empty or @ (exception) or ? (emulation rule)
* @param {string} selector raw CSS selector
* @return {ElemHideFilter|ElemHideException|
* ElemHideEmulationFilter|InvalidFilter}
*/
-ElemHideBase.fromText = function(text, domain, type, selector)
+ElemHideBase.fromText = function(text, domains, type, selector)
{
// We don't allow ElemHide filters which have any empty domains.
// Note: The ElemHide.prototype.domainSeparator is duplicated here, if that
// changes this must be changed too.
- if (domain && /(^|,)~?(,|$)/.test(domain))
+ if (domains && /(^|,)~?(,|$)/.test(domains))
return new InvalidFilter(text, "filter_invalid_domain");
if (type == "@")
- return new ElemHideException(text, domain, selector);
+ return new ElemHideException(text, domains, selector);
if (type == "?")
{
// Element hiding emulation filters are inefficient so we need to make sure
// that they're only applied if they specify active domains
- if (!/,[^~][^,.]*\.[^,]/.test("," + domain))
+ if (!/,[^~][^,.]*\.[^,]/.test("," + domains))
return new InvalidFilter(text, "filter_elemhideemulation_nodomain");
- return new ElemHideEmulationFilter(text, domain, selector);
+ return new ElemHideEmulationFilter(text, domains, selector);
}
- return new ElemHideFilter(text, domain, selector);
+ return new ElemHideFilter(text, domains, selector);
};
/**
* Class for element hiding filters
* @param {string} text see Filter()
* @param {string} domains see ElemHideBase()
* @param {string} selector see ElemHideBase()
* @constructor
« no previous file with comments | « no previous file | test/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld