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

Unified Diff: lib/filterClasses.js

Issue 29336430: Issue 3659 - Remove locale dependency from filter classes (Closed)
Patch Set: Created Feb. 16, 2016, 11:45 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 | « README.md ('k') | package.json » ('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
@@ -15,17 +15,16 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @fileOverview Definition of Filter class and its subclasses.
*/
let {FilterNotifier} = require("filterNotifier");
-let {Utils} = require("utils");
/**
* Abstract base class for filters
*
* @param {String} text string representation of the filter
* @constructor
*/
function Filter(text)
@@ -732,30 +731,30 @@ RegExpFilter.fromText = function(text)
thirdParty = false;
else if (option == "COLLAPSE")
collapse = true;
else if (option == "~COLLAPSE")
collapse = false;
else if (option == "SITEKEY" && typeof value != "undefined")
sitekeys = value;
else
- return new InvalidFilter(origText, "Unknown option " + option.toLowerCase());
+ return new InvalidFilter(origText, "filter_unknown_option");
}
}
try
{
if (blocking)
return new BlockingFilter(origText, text, contentType, matchCase, domains, thirdParty, sitekeys, collapse);
else
return new WhitelistFilter(origText, text, contentType, matchCase, domains, thirdParty, sitekeys);
}
catch (e)
{
- return new InvalidFilter(origText, e);
+ return new InvalidFilter(origText, "filter_invalid_regexp");
}
};
/**
* Maps type strings like "SCRIPT" or "OBJECT" to bit masks
*/
RegExpFilter.typeMap = {
OTHER: 1,
@@ -922,41 +921,41 @@ ElemHideBase.fromText = function(text, d
if (separatorPos > 0)
{
rule = rule.replace(/=/, '="') + '"';
additional += "[" + rule + "]";
}
else
{
if (id)
- return new InvalidFilter(text, Utils.getString("filter_elemhide_duplicate_id"));
+ return new InvalidFilter(text, "filter_elemhide_duplicate_id");
id = rule;
}
}
}
if (id)
selector = tagName + "." + id + additional + "," + tagName + "#" + id + additional;
else if (tagName || additional)
selector = tagName + additional;
else
- return new InvalidFilter(text, Utils.getString("filter_elemhide_nocriteria"));
+ return new InvalidFilter(text, "filter_elemhide_nocriteria");
}
if (isException)
return new ElemHideException(text, domain, selector);
let match = Filter.csspropertyRegExp.exec(selector);
if (match)
{
// CSS property filters are inefficient so we need to make sure that
// they're only applied if they specify active domains
if (!/,[^~][^,.]*\.[^,]/.test("," + domain))
- return new InvalidFilter(text, Utils.getString("filter_cssproperty_nodomain"));
+ return new InvalidFilter(text, "filter_cssproperty_nodomain");
return new CSSPropertyFilter(text, domain, selector, match[2],
selector.substr(0, match.index),
selector.substr(match.index + match[0].length));
}
return new ElemHideFilter(text, domain, selector);
};
« no previous file with comments | « README.md ('k') | package.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld