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

Unified Diff: lib/rsa.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/matcher.js ('k') | test/_common.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/rsa.js
===================================================================
--- a/lib/rsa.js
+++ b/lib/rsa.js
@@ -99,20 +99,23 @@
}
function readNode(curTempl)
{
let type = next();
let len = readLength();
if ("type" in curTempl && curTempl.type != type)
throw "Unexpected type";
- if ("content" in curTempl && curTempl.content != data.substr(pos, len))
+ if ("content" in curTempl &&
+ curTempl.content != data.substring(pos, pos + len))
+ {
throw "Unexpected content";
+ }
if ("out" in curTempl)
- out[curTempl.out] = new BigInteger(data.substr(pos, len), 256);
+ out[curTempl.out] = new BigInteger(data.substring(pos, pos + len), 256);
if ("children" in curTempl)
{
let i;
let end;
for (i = 0, end = pos + len; pos < end; i++)
{
if (i >= curTempl.children.length)
throw "Too many children";
@@ -188,17 +191,17 @@
if (next() != 1)
throw "Wrong padding in signature digest";
while (next() == 255) {}
if (digest.charCodeAt(pos - 1) != 0)
throw "Wrong padding in signature digest";
// Rest is an ASN.1 structure, get the SHA1 hash from it and compare to
// the real one
- let {sha1} = readASN1(digest.substr(pos), signatureTemplate);
+ let {sha1} = readASN1(digest.substring(pos), signatureTemplate);
let expected = new BigInteger(rusha.digest(data), 16);
return (sha1.compareTo(expected) == 0);
}
catch (e)
{
console.warn("Invalid encrypted signature: " + e);
return false;
}
« no previous file with comments | « lib/matcher.js ('k') | test/_common.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld