From b01e63e2cdd4d7782fa791434f84bdbd07deff65 Mon Sep 17 00:00:00 2001 From: radius Date: Wed, 14 Mar 2018 22:59:36 -0500 Subject: [PATCH] make sure to always encode urls, also change the PS3 default urls --- config.def.h | 6 +++--- libretro-common/net/net_http.c | 2 +- tasks/task_http.c | 25 ++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/config.def.h b/config.def.h index fcb3ba989e..e7c29ab786 100644 --- a/config.def.h +++ b/config.def.h @@ -719,11 +719,11 @@ static char buildbot_server_url[] = ""; #elif defined(WIIU) static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/nintendo/wiiu/latest/"; #elif defined(__CELLOS_LV2__) && defined(DEX_BUILD) -static char buildbot_server_url[] = "http://xbins.org/libretro/nightly/playstation/ps3/latest/dex-ps3/"; +static char buildbot_server_url[] = "http://libretro.xbins.org/libretro/nightly/playstation/ps3/latest/dex-ps3/"; #elif defined(__CELLOS_LV2__) && defined(CEX_BUILD) -static char buildbot_server_url[] = "http://xbins.org/libretro/nightly/playstation/ps3/latest/cex-ps3/"; +static char buildbot_server_url[] = "http://libretro.xbins.org/libretro/nightly/playstation/ps3/latest/cex-ps3/"; #elif defined(__CELLOS_LV2__) && defined(ODE_BUILD) -static char buildbot_server_url[] = "http://xbins.org/libretro/nightly/playstation/ps3/latest/ode-ps3/"; +static char buildbot_server_url[] = "http://libretro.xbins.org/libretro/nightly/playstation/ps3/latest/ode-ps3/"; #else static char buildbot_server_url[] = ""; #endif diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index fb40d89b7d..41d92403a6 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -97,7 +97,7 @@ void urlencode_lut_init() for (i = 0; i < 256; i++) { - urlencode_lut[i] = isalnum(i) || i == '*' || i == '-' || i == '.' || i == '_' ? i : (i == ' ') ? '+' : 0; + urlencode_lut[i] = isalnum(i) || i == '*' || i == '-' || i == '.' || i == '_' || i == '/' ? i : 0; } } diff --git a/tasks/task_http.c b/tasks/task_http.c index 9608133854..d174c6cccf 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -320,9 +320,32 @@ void* task_push_http_transfer(const char *url, bool mute, retro_task_callback_t cb, void *user_data) { struct http_connection_t *conn; + char *tmp; + char url_domain[PATH_MAX_LENGTH]; + char url_path[PATH_MAX_LENGTH]; + char url_encoded[PATH_MAX_LENGTH]; - conn = net_http_connection_new(url, "GET", NULL); + int count = 0; + strlcpy (url_path, url, sizeof(url_path)); + tmp = url_path; + while (count < 3 && tmp[0] != '\0') + { + tmp = strchr(tmp, '/'); + count ++; + tmp++; + } + + strlcpy(url_domain, url, tmp - url_path); + strlcpy(url_path, tmp, sizeof(url_path)); + + tmp = NULL; + net_http_urlencode_full (&tmp, url_path); + snprintf(url_encoded, sizeof(url_encoded), "%s/%s", url_domain, tmp); + + conn = net_http_connection_new(url_encoded, "GET", NULL); + + free (tmp); return task_push_http_transfer_generic(conn, url, mute, type, cb, user_data); }