Fix UrlSafeBase64Encode function

This commit is contained in:
RainLoop Team 2016-08-31 22:00:48 +03:00
parent 6b1fd1239f
commit 969f15dd6b

View file

@ -1721,7 +1721,7 @@ END;
*/
public static function UrlSafeBase64Encode($sValue)
{
return \str_replace(array('+', '/', '='), array('-', '_', '.'), \base64_encode($sValue));
return \rtrim(\strtr(\base64_encode(\trim($sValue)), '+/', '-_'), '=');
}
/**
@ -1731,14 +1731,8 @@ END;
*/
public static function UrlSafeBase64Decode($sValue)
{
$sData = \str_replace(array('-', '_', '.'), array('+', '/', '='), $sValue);
$sMode = \strlen($sData) % 4;
if ($sMode)
{
$sData .= \substr('====', $sMode);
}
return \MailSo\Base\Utils::Base64Decode($sData);
$sValue = \rtrim(\strtr($sValue, '-_.', '+/='), '=');
return \MailSo\Base\Utils::Base64Decode(\str_pad($sValue, \strlen($sValue) % 4, '=', STR_PAD_RIGHT));
}
/**