From 1fc7a50f3e07a199bf626b22fea520e84e26c6b5 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Sat, 4 Mar 2017 19:27:49 +0000 Subject: [PATCH] fix non-ascii URL encoding --- libretro-common/net/net_http.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index 02d28f341a..632c158f3a 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -85,7 +85,6 @@ void urlencode_lut_init() for (i = 0; i < 256; i++) { - urlencode_lut[i] = isalnum(i) || i == '*' || i == '-' || i == '.' || i == '_' ? i : (i == ' ') ? '+' : 0; } } @@ -107,11 +106,11 @@ void net_http_urlencode_full(char **dest, const char *source) { { /* any non-ascii character will just be encoded without question */ if ((int)*source < sizeof(urlencode_lut) && urlencode_lut[(int)*source]) - sprintf(enc, "%c", urlencode_lut[(int)*source]); + snprintf(enc, len, "%c", urlencode_lut[(int)*source]); else - sprintf(enc, "%%%02X", *source); + snprintf(enc, len, "%%%02X", *source & 0xFF); - while (*++(enc)); + while (*++enc); } (*dest)[len - 1] = '\0';