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

Unified Diff: lib/filterClasses.js

Issue 30011555: Issue 7303 - Deprecate the use of String.prototype.substr() (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Rebase. Revert changes in hot path. Created Feb. 21, 2019, 6:09 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 | « lib/content/elemHideEmulation.js ('k') | lib/matcher.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
@@ -314,28 +314,28 @@
let strippedDollarIndex = -1;
let dollarIndex = -1;
do
{
strippedDollarIndex = beforeOptions.indexOf("$", strippedDollarIndex + 1);
dollarIndex = text.indexOf("$", dollarIndex + 1);
}
while (strippedDollarIndex != -1);
- let optionsText = text.substr(dollarIndex + 1);
+ let optionsText = text.substring(dollarIndex + 1);
// Then we can normalize spaces in the options part safely
let options = optionsText.split(",");
for (let i = 0; i < options.length; i++)
{
let option = options[i];
let cspMatch = /^ *c *s *p *=/i.exec(option);
if (cspMatch)
{
options[i] = cspMatch[0].replace(/ +/g, "") +
- option.substr(cspMatch[0].length).trim().replace(/ +/g, " ");
+ option.substring(cspMatch[0].length).trim().replace(/ +/g, " ");
}
else
options[i] = option.replace(/ +/g, "");
}
return beforeOptions + "$" + options.join();
};
@@ -526,17 +526,17 @@
let domain = list[i];
if (domain == "")
continue;
let include;
if (domain[0] == "~")
{
include = false;
- domain = domain.substr(1);
+ domain = domain.substring(1);
}
else
{
include = true;
hasIncludes = true;
}
if (!domains)
@@ -725,17 +725,17 @@
this.resourceName = resourceName;
if (regexpSource.length >= 2 &&
regexpSource[0] == "/" &&
regexpSource[regexpSource.length - 1] == "/")
{
// The filter is a regular expression - convert it immediately to
// catch syntax errors
- let regexp = new RegExp(regexpSource.substr(1, regexpSource.length - 2),
+ let regexp = new RegExp(regexpSource.substring(1, regexpSource.length - 1),
this.matchCase ? "" : "i");
Object.defineProperty(this, "regexp", {value: regexp});
}
else
{
// Patterns like /foo/bar/* exist so that they are not treated as regular
// expressions. We drop any superfluous wildcards here so our optimizations
// can kick in.
@@ -970,47 +970,47 @@
*/
RegExpFilter.fromText = function(text)
{
let blocking = true;
let origText = text;
if (text[0] == "@" && text[1] == "@")
{
blocking = false;
- text = text.substr(2);
+ text = text.substring(2);
}
let contentType = null;
let matchCase = null;
let domains = null;
let sitekeys = null;
let thirdParty = null;
let collapse = null;
let csp = null;
let rewrite = null;
let resourceName = null;
let options;
let match = text.includes("$") ? Filter.optionsRegExp.exec(text) : null;
if (match)
{
options = match[1].split(",");
- text = match.input.substr(0, match.index);
+ text = match.input.substring(0, match.index);
for (let option of options)
{
let value = null;
let separatorIndex = option.indexOf("=");
if (separatorIndex >= 0)
{
- value = option.substr(separatorIndex + 1);
- option = option.substr(0, separatorIndex);
+ value = option.substring(separatorIndex + 1);
+ option = option.substring(0, separatorIndex);
}
let inverse = option[0] == "~";
if (inverse)
- option = option.substr(1);
+ option = option.substring(1);
let type = RegExpFilter.typeMap[option.replace(/-/, "_").toUpperCase()];
if (type)
{
if (inverse)
{
if (contentType == null)
({contentType} = RegExpFilter.prototype);
@@ -1051,17 +1051,17 @@
return new InvalidFilter(origText, "filter_unknown_option");
sitekeys = value.toUpperCase();
break;
case "rewrite":
if (value == null)
return new InvalidFilter(origText, "filter_unknown_option");
rewrite = value;
if (value.startsWith("abp-resource:"))
- resourceName = value.substr("abp-resource:".length);
+ resourceName = value.substring("abp-resource:".length);
break;
default:
return new InvalidFilter(origText, "filter_unknown_option");
}
}
}
}
« no previous file with comments | « lib/content/elemHideEmulation.js ('k') | lib/matcher.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld