From: Schanzenbach, Martin Date: Mon, 1 Oct 2018 15:27:14 +0000 (+0200) Subject: urlencode base64 X-Git-Tag: v0.11.0~241^2~4 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b1920f97583d6a75c4886715aa0335699c9af13a;p=oweals%2Fgnunet.git urlencode base64 --- diff --git a/src/rest-plugins/plugin_rest_openid_connect.c b/src/rest-plugins/plugin_rest_openid_connect.c index 2bcf576fb..2e68b7f99 100644 --- a/src/rest-plugins/plugin_rest_openid_connect.c +++ b/src/rest-plugins/plugin_rest_openid_connect.c @@ -648,7 +648,7 @@ return_userinfo_response (void *cls) } /** - * Returns base64 encoded string without padding + * Returns base64 encoded string urlencoded * * @param string the string to encode * @return base64 encoded string @@ -657,12 +657,27 @@ static char* base_64_encode(const char *s) { char *enc; + char *enc_urlencode; char *tmp; + int i; + int num_pads = 0; GNUNET_STRINGS_base64_encode(s, strlen(s), &enc); - tmp = strrchr (enc, '='); - *tmp = '\0'; - return enc; + tmp = strchr (enc, '='); + num_pads = strlen (enc) - (tmp - enc); + GNUNET_assert ((3 > num_pads) && (0 <= num_pads)); + if (0 == num_pads) + return enc; + enc_urlencode = GNUNET_malloc (strlen (enc) + num_pads*2); + strcpy (enc_urlencode, enc); + GNUNET_free (enc); + tmp = strchr (enc_urlencode, '='); + for (i = 0; i < num_pads; i++) + { + strcpy (tmp, "%3D"); //replace '=' with '%3D' + tmp += 3; + } + return enc_urlencode; } /**