diff --git a/src/Base64.php b/src/Base64.php index e090613..e75aa4f 100644 --- a/src/Base64.php +++ b/src/Base64.php @@ -245,18 +245,12 @@ public static function decodeNoPadding( return ''; } if (($srcLen & 3) === 0) { - if ($encodedString[$srcLen - 1] === '=') { + // If $strLen is not zero and it is divisible by 4, then its at least 4. + if ($encodedString[$srcLen - 1] === '=' || $encodedString[$srcLen - 2] === '=') { throw new InvalidArgumentException( "decodeNoPadding() doesn't tolerate padding" ); } - if (($srcLen & 3) > 1) { - if ($encodedString[$srcLen - 2] === '=') { - throw new InvalidArgumentException( - "decodeNoPadding() doesn't tolerate padding" - ); - } - } } return static::decode( $encodedString,