net.php: remove base64 padding from encoded cursor

This commit is contained in:
Zankaria 2024-10-24 21:10:51 +02:00
parent e3b89dcc9d
commit 894d5a4b8b

View file

@ -20,14 +20,14 @@ function is_connection_secure(): bool {
* Encodes a string into a base64 variant without characters illegal in urls.
*/
function base64_url_encode(string $input): string {
return strtr(base64_encode($input), '+/=', '-_.');
return str_replace([ '+', '/', '=' ], [ '-', '_', '' ], base64_encode($input));
}
/**
* Decodes a string from a base64 variant without characters illegal in urls.
*/
function base64_url_decode(string $input): string {
return base64_decode(strtr($input, '-_.', '+/='));
return base64_decode(strtr($input, '-_', '+/'));
}
/**