summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeuman Vong <neuman@twilio.com>2011-04-27 17:16:15 -0700
committerNeuman Vong <neuman@twilio.com>2011-04-27 17:16:15 -0700
commit6fc8c26b54ebb7f5e81a14b5b65fa09995fe1cb1 (patch)
tree966a8a701a29c357df5b76beeced00beaf869ec3
parent45e376552e8dddea150d5548412f089ca32c0b3a (diff)
downloadphp-jwt-6fc8c26b54ebb7f5e81a14b5b65fa09995fe1cb1.zip
php-jwt-6fc8c26b54ebb7f5e81a14b5b65fa09995fe1cb1.tar.gz
php-jwt-6fc8c26b54ebb7f5e81a14b5b65fa09995fe1cb1.tar.bz2
Stop padding inputs already divisible by 4
-rw-r--r--JWT.php7
1 files changed, 5 insertions, 2 deletions
diff --git a/JWT.php b/JWT.php
index d1704e1..2bfb147 100644
--- a/JWT.php
+++ b/JWT.php
@@ -127,8 +127,11 @@ class JWT
*/
public static function urlsafeB64Decode($input)
{
- $padlen = 4 - strlen($input) % 4;
- $input .= str_repeat('=', $padlen);
+ $remainder = strlen($input) % 4;
+ if ($remainder) {
+ $padlen = 4 - $remainder;
+ $input .= str_repeat('=', $padlen);
+ }
return base64_decode(strtr($input, '-_', '+/'));
}