diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2018-10-01 17:27:14 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2018-10-01 17:27:14 +0200 |
commit | b1920f97583d6a75c4886715aa0335699c9af13a (patch) | |
tree | fbac31bc4448613bcfee8c395f22aaeca942525f /src | |
parent | 13274f4bd2009dd928e91f0b6e056cee7f7975a5 (diff) | |
download | gnunet-b1920f97583d6a75c4886715aa0335699c9af13a.tar.gz gnunet-b1920f97583d6a75c4886715aa0335699c9af13a.zip |
urlencode base64
Diffstat (limited to 'src')
-rw-r--r-- | src/rest-plugins/plugin_rest_openid_connect.c | 23 |
1 files changed, 19 insertions, 4 deletions
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) | |||
648 | } | 648 | } |
649 | 649 | ||
650 | /** | 650 | /** |
651 | * Returns base64 encoded string without padding | 651 | * Returns base64 encoded string urlencoded |
652 | * | 652 | * |
653 | * @param string the string to encode | 653 | * @param string the string to encode |
654 | * @return base64 encoded string | 654 | * @return base64 encoded string |
@@ -657,12 +657,27 @@ static char* | |||
657 | base_64_encode(const char *s) | 657 | base_64_encode(const char *s) |
658 | { | 658 | { |
659 | char *enc; | 659 | char *enc; |
660 | char *enc_urlencode; | ||
660 | char *tmp; | 661 | char *tmp; |
662 | int i; | ||
663 | int num_pads = 0; | ||
661 | 664 | ||
662 | GNUNET_STRINGS_base64_encode(s, strlen(s), &enc); | 665 | GNUNET_STRINGS_base64_encode(s, strlen(s), &enc); |
663 | tmp = strrchr (enc, '='); | 666 | tmp = strchr (enc, '='); |
664 | *tmp = '\0'; | 667 | num_pads = strlen (enc) - (tmp - enc); |
665 | return enc; | 668 | GNUNET_assert ((3 > num_pads) && (0 <= num_pads)); |
669 | if (0 == num_pads) | ||
670 | return enc; | ||
671 | enc_urlencode = GNUNET_malloc (strlen (enc) + num_pads*2); | ||
672 | strcpy (enc_urlencode, enc); | ||
673 | GNUNET_free (enc); | ||
674 | tmp = strchr (enc_urlencode, '='); | ||
675 | for (i = 0; i < num_pads; i++) | ||
676 | { | ||
677 | strcpy (tmp, "%3D"); //replace '=' with '%3D' | ||
678 | tmp += 3; | ||
679 | } | ||
680 | return enc_urlencode; | ||
666 | } | 681 | } |
667 | 682 | ||
668 | /** | 683 | /** |