mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-02-22 13:53:14 +08:00
Fix UrlSafeBase64Encode function
This commit is contained in:
parent
6b1fd1239f
commit
969f15dd6b
1 changed files with 3 additions and 9 deletions
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue