File tree Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -82,8 +82,12 @@ function base (ALPHABET) {
8282 const b256 = new Uint8Array ( size )
8383 // Process the characters.
8484 while ( psz < source . length ) {
85+ // Find code of next character
86+ const charCode = source . charCodeAt ( psz )
87+ // Base map can not be indexed using char code
88+ if ( charCode > 255 ) { return }
8589 // Decode character
86- let carry = BASE_MAP [ source . charCodeAt ( psz ) ]
90+ let carry = BASE_MAP [ charCode ]
8791 // Invalid character
8892 if ( carry === 255 ) { return }
8993 let i = 0
Original file line number Diff line number Diff line change @@ -80,8 +80,12 @@ function base (ALPHABET) {
8080 const b256 = new Uint8Array ( size )
8181 // Process the characters.
8282 while ( psz < source . length ) {
83+ // Find code of next character
84+ const charCode = source . charCodeAt ( psz )
85+ // Base map can not be indexed using char code
86+ if ( charCode > 255 ) { return }
8387 // Decode character
84- let carry = BASE_MAP [ source . charCodeAt ( psz ) ]
88+ let carry = BASE_MAP [ charCode ]
8589 // Invalid character
8690 if ( carry === 255 ) { return }
8791 let 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 @@ -101,8 +101,14 @@ function base (ALPHABET: string): base.BaseConverter {
101101
102102 // Process the characters.
103103 while ( psz < source . length ) {
104+ // Find code of next character
105+ const charCode = source . charCodeAt ( psz )
106+
107+ // Base map can not be indexed using char code
108+ if ( charCode > 255 ) return
109+
104110 // Decode character
105- let carry = BASE_MAP [ source . charCodeAt ( psz ) ]
111+ let carry = BASE_MAP [ charCode ]
106112
107113 // Invalid character
108114 if ( carry === 255 ) return
You can’t perform that action at this time.
0 commit comments