Explicit check for invalid characters in Base58 decoder.
This commit is contained in:
parent
faa10f0f6a
commit
c952aaeb3e
1 changed files with 4 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
(function (Bitcoin) {
|
||||
Bitcoin.Base58 = {
|
||||
alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",
|
||||
validRegex: /^[1-9A-HJ-NP-Za-km-z]+$/,
|
||||
base: BigInteger.valueOf(58),
|
||||
|
||||
/**
|
||||
|
@ -45,6 +46,9 @@
|
|||
var leadingZerosNum = 0;
|
||||
for (var i = input.length - 1; i >= 0; i--) {
|
||||
var alphaIndex = B58.alphabet.indexOf(input[i]);
|
||||
if (alphaIndex < 0) {
|
||||
throw "Invalid character";
|
||||
}
|
||||
bi = bi.add(BigInteger.valueOf(alphaIndex)
|
||||
.multiply(B58.base.pow(input.length - 1 -i)));
|
||||
|
||||
|
|
Loading…
Reference in a new issue