Using [A-z] in the regex brings in non-alphanumeric characters between the uppercase and lowercase alphabets, meaning the following chars were not correctly stripped from base 64 strings: left and right square bracket, backslash, caret, underline, and backtick. Explicitly separating the uppercase and lowercase letter ranges fixes this.
return arr
}
-var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g
+var INVALID_BASE64_RE = /[^+\/0-9A-Za-z\-]/g
function base64clean (str) {
// Node strips out invalid characters like \n and \t from the string, base64-js does not