Strip trailing slashes from download server URL.

If the server sends us an URL with trailing slash we're generating URIs
like http://example.com//maps/foo.bsp. While double // are perfectly
valid they might me rejected by some servers. So let's play save.
This commit is contained in:
Yamagi Burmeister 2019-01-20 10:15:29 +01:00
parent e05f95e3fb
commit 5e67596d56
1 changed files with 12 additions and 1 deletions

View File

@ -920,7 +920,18 @@ void CL_SetHTTPServer (const char *URL)
abortDownloads = HTTPDL_ABORT_NONE;
handleCount = pendingCount = 0;
cls.downloadServerRetry[0] = 0;
Q_strlcpy(cls.downloadServer, URL, sizeof(cls.downloadServer) - 1);
// Remove trailing / from URL if any.
size_t urllen = strlen(URL);
char *cleanURL = strdup(URL);
if (cleanURL[urllen - 1] == '/')
{
cleanURL[urllen - 1] = '\0';
}
Q_strlcpy(cls.downloadServer, cleanURL, sizeof(cls.downloadServer) - 1);
free(cleanURL);
// Initializes a new multihandle.
if (multi)