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 @@ -81,8 +81,12 @@ function base (ALPHABET) {
8181 var b256 = new Uint8Array ( size )
8282 // Process the characters.
8383 while ( source [ psz ] ) {
84+ // Find code of next character
85+ var charCode = source . charCodeAt ( psz )
86+ // Base map can not be indexed using char code
87+ if ( charCode > 255 ) { return }
8488 // Decode character
85- var carry = BASE_MAP [ source . charCodeAt ( psz ) ]
89+ var carry = BASE_MAP [ charCode ]
8690 // Invalid character
8791 if ( carry === 255 ) { return }
8892 var i = 0
Original file line number Diff line number Diff line change 660660 "alphabet" : " 0123456789fabcdef" ,
661661 "description" : " poorly formed alphabet" ,
662662 "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 "
663669 }
664670 ]
665671}
Original file line number Diff line number Diff line change @@ -100,8 +100,14 @@ function base (ALPHABET: string): base.BaseConverter {
100100
101101 // Process the characters.
102102 while ( source [ psz ] ) {
103+ // Find code of next character
104+ const charCode = source . charCodeAt ( psz )
105+
106+ // Base map can not be indexed using char code
107+ if ( charCode > 255 ) return
108+
103109 // Decode character
104- let carry = BASE_MAP [ source . charCodeAt ( psz ) ]
110+ let carry = BASE_MAP [ charCode ]
105111
106112 // Invalid character
107113 if ( carry === 255 ) return
You can’t perform that action at this time.
0 commit comments