diff --git a/lib/buffer.js b/lib/buffer.js index b9e2fc9b2253bf..bbb393b94c844c 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -1280,7 +1280,7 @@ function atob(input) { // ASCII whitespace char codes. nonAsciiWhitespaceCharCount++; - if (index === kForgivingBase64AllowedChars.length - 1) { + if (index === kForgivingBase64AllowedChars.length - 1 && equalCharCount !== 2) { // The last element of `kForgivingBase64AllowedChars` is the `=` equalCharCount++; } else if (equalCharCount) {