Commit 1abf871c authored by Ilkka Ollakka's avatar Ilkka Ollakka

httplive: handle better relative urls

if path starts with / it's related to root of server and not
current path.

Fixes: #8321
parent 12ae705d
...@@ -547,10 +547,18 @@ static char *relative_URI(const char *psz_url, const char *psz_path) ...@@ -547,10 +547,18 @@ static char *relative_URI(const char *psz_url, const char *psz_path)
if (strncmp(psz_path, "http", 4) == 0) if (strncmp(psz_path, "http", 4) == 0)
return NULL; return NULL;
char *path_end = strrchr(psz_url, '/'); char *path_separator=NULL;
if (path_end == NULL) if( psz_path[0] == '/' ) //Relative URL with absolute path
{
//Try to find separator for name and path, try to skip
//access and first ://
path_separator = strchr( &psz_url[8], '/');
} else {
path_separator = strrchr(psz_url, '/');
}
if ( unlikely( path_separator == NULL ) )
return NULL; return NULL;
unsigned int url_length = path_end - psz_url + 1; const size_t url_length = path_separator - psz_url + 1;
char *psz_res = malloc(url_length + strlen(psz_path) + 1); char *psz_res = malloc(url_length + strlen(psz_path) + 1);
strncpy(psz_res, psz_url, url_length); strncpy(psz_res, psz_url, url_length);
psz_res[url_length] = 0; psz_res[url_length] = 0;
......
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