Commit 12f3ef00 authored by Romain FLIEDEL's avatar Romain FLIEDEL Committed by Jean-Baptiste Kempf

httplive: fix wrong url when computing relative uri.

Remove extra slash when computing relative uri with an absolute path.
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 28fd6664
......@@ -566,6 +566,7 @@ static int string_to_IV(char *string_hexa, uint8_t iv[AES_BLOCK_SIZE])
static char *relative_URI(const char *psz_url, const char *psz_path)
{
char *ret = NULL;
const char *fmt;
assert(psz_url != NULL && psz_path != NULL);
......@@ -587,6 +588,7 @@ static char *relative_URI(const char *psz_url, const char *psz_path)
if (unlikely(slash == NULL))
goto end;
*slash = '\0';
fmt = "%s%s";
} else {
int levels = 0;
while(len >= 3 && !strncmp(psz_path, "../", 3)) {
......@@ -600,9 +602,10 @@ static char *relative_URI(const char *psz_url, const char *psz_path)
goto end;
*slash = '\0';
} while (levels--);
fmt = "%s/%s";
}
if (asprintf(&ret, "%s/%s", new_url, psz_path) < 0)
if (asprintf(&ret, fmt, new_url, psz_path) < 0)
ret = NULL;
end:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment