Skip to content

Commit 6fc8c26

Browse files
author
Neuman Vong
committed
Stop padding inputs already divisible by 4
1 parent 45e3765 commit 6fc8c26

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

JWT.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,11 @@ public static function jsonEncode($input)
127127
*/
128128
public static function urlsafeB64Decode($input)
129129
{
130-
$padlen = 4 - strlen($input) % 4;
131-
$input .= str_repeat('=', $padlen);
130+
$remainder = strlen($input) % 4;
131+
if ($remainder) {
132+
$padlen = 4 - $remainder;
133+
$input .= str_repeat('=', $padlen);
134+
}
132135
return base64_decode(strtr($input, '-_', '+/'));
133136
}
134137

0 commit comments

Comments
 (0)