File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -78,8 +78,12 @@ function base (ALPHABET) {
78
78
var b256 = new Uint8Array ( size )
79
79
// Process the characters.
80
80
while ( psz < source . length ) {
81
+ // Find code of next character
82
+ var charCode = source . charCodeAt ( psz )
83
+ // Base map can not be indexed using char code
84
+ if ( charCode > 255 ) { return }
81
85
// Decode character
82
- var carry = BASE_MAP [ source . charCodeAt ( psz ) ]
86
+ var carry = BASE_MAP [ charCode ]
83
87
// Invalid character
84
88
if ( carry === 255 ) { return }
85
89
var i = 0
Original file line number Diff line number Diff line change 660
660
"alphabet" : " 0123456789fabcdef" ,
661
661
"description" : " poorly formed alphabet" ,
662
662
"exception" : " ^TypeError: f is ambiguous$"
663
+ },
664
+ {
665
+ "alphabet" : " base58" ,
666
+ "description" : " character whose code exceeds the highest index of base map (>=256)" ,
667
+ "exception" : " ^Error: Non-base58 character$" ,
668
+ "string" : " \u1000 "
663
669
}
664
670
]
665
671
}
Original file line number Diff line number Diff line change @@ -98,8 +98,14 @@ function base (ALPHABET: string): base.BaseConverter {
98
98
99
99
// Process the characters.
100
100
while ( psz < source . length ) {
101
+ // Find code of next character
102
+ const charCode = source . charCodeAt ( psz )
103
+
104
+ // Base map can not be indexed using char code
105
+ if ( charCode > 255 ) return
106
+
101
107
// Decode character
102
- let carry = BASE_MAP [ source . charCodeAt ( psz ) ]
108
+ let carry = BASE_MAP [ charCode ]
103
109
104
110
// Invalid character
105
111
if ( carry === 255 ) return
You can’t perform that action at this time.
0 commit comments