diff --git a/packages/base64/src/decode.js b/packages/base64/src/decode.js index 5d44d666e8..6c8fea3a8f 100644 --- a/packages/base64/src/decode.js +++ b/packages/base64/src/decode.js @@ -44,14 +44,14 @@ export const jsDecodeBase64 = (string, name = '') => { i += 1; } - while (quantum % 8 !== 0) { + while (quantum > 0) { if (i === string.length || string[i] !== padding) { throw Error(`Missing padding at offset ${i} of string ${name}`); } // We MAY reject non-zero padding bits, but choose not to. // https://datatracker.ietf.org/doc/html/rfc4648#section-3.5 i += 1; - quantum += 6; + quantum -= 2; } if (i < string.length) {