Skip to content

Commit bcd6004

Browse files
author
Nicholas C. Zakas
committed
Now detect invalid padding
1 parent 2b187a1 commit bcd6004

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

encodings/base64/base64.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function base64Decode(text){
8383
text = text.replace(/\s/g,"");
8484

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

0 commit comments

Comments
 (0)