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) {
7878    var  b256  =  new  Uint8Array ( size ) 
7979        // Process the characters. 
8080    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  } 
8185            // Decode character 
82-       var  carry  =  BASE_MAP [ source . charCodeAt ( psz ) ] 
86+       var  carry  =  BASE_MAP [ charCode ] 
8387            // Invalid character 
8488      if  ( carry  ===  255 )  {  return  } 
8589      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 @@ -98,8 +98,14 @@ function base (ALPHABET: string): base.BaseConverter {
9898
9999    // Process the characters. 
100100    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+ 
101107      // Decode character 
102-       let  carry  =  BASE_MAP [ source . charCodeAt ( psz ) ] 
108+       let  carry  =  BASE_MAP [ charCode ] 
103109
104110      // Invalid character 
105111      if  ( carry  ===  255 )  return 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments