Skip to content

Commit

Permalink
Now detect invalid padding
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas C. Zakas committed Nov 28, 2009
1 parent 2b187a1 commit bcd6004
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion encodings/base64/base64.js
Expand Up @@ -83,7 +83,7 @@ function base64Decode(text){
text = text.replace(/\s/g,"");

//first check for any unexpected input
if(!(/^[a-z0-9\+\/\s]+\={0,2}$/i.test(text)) | text.length % 4 > 0){
if(!(/^[a-z0-9\+\/\s]+\={0,2}$/i.test(text)) || text.length % 4 > 0){
throw new Error("Not a base64-encoded string.");
}

Expand Down

0 comments on commit bcd6004

Please sign in to comment.